How can I set up remote directories in Git where I can locally push a stage branch to the remote and see the live changes on a staging server, like stage.example.com?
The notion I have (part of why I am moving away from SVN) is that I can maintain (locally) 3 different "main" branches as follows:
- master - used for local development, working dir
- stage - should be in-sync with staging server directory (remote)
- live - this should be the publicly accessible website (remote)
The idea I have (and what others claim is possible) is that I can maintain these remote "sites" from my local computer without having to constantly log into my remote server shell and run svn update
(in my current svn workflow I need to do this all the time…) or of course in my Git workflow run git pull
on the remote.
How can I setup the remote directories so that I can locally push my stage
branch to the staging remote server
and see the changes on (for example) stage.example.com
right away?
Then once the stage
is all okay and tested I would just locally be able to push
to the live
remote to make these changes that I have tested on the stage
to the live website.
Can this even be done or am I getting crazy ideas here that are simply not meant to be done with Git?
In case this is of importance here are a few stats about my local and remote servers:
remote server: Dreamhost (shared account) remote GIT version: 1.7.1.1 remote GIT client: shell local computer: Mac Pro (Snow Leopard 10.6.6) local GIT version: 1.7.2.3 local GIT client: Tower.app // git-tower.com
Also, so far I have unsuccessfully tried the following workflow:
- Create a
--bare
Git repo on the remote (so I can access it from everywhere) - Clone this remote repo to a local directory and the use Git Tower app to manage it
- Work locally in
master (HEAD)
scp -r
copy the--bare
git repo from the remote server into my remote live domainstage.example.com
- Add remote to local working copy and then try to push to
origin/stage
Clearly this doesn't work but I don't know why or how to do it any better.
Coming from a SVN background I'm new to Git but have watched plenty of tutorials (Peepcode & ThinkVitamin) but still cannot figure out how to set this up.