Your mileage and strategy may vary depending on your workflow. What I describe below is working for us at my current company, but feel free to experiment and find what works for you.
In our Git repo, we have a "master" branch. All new development, as well as major bug fixes, occur in branches off of the "master" branch. When they're ready, they are merge into master. The idea here is that no unfinished features or knowingly buggy code is ever in master (in theory…).
When we want to make a new "release" - a new version of the code on our web site - I contact the other developers and make sure the stuff they were working on which should be done has been merged into master and pushed to the GitHub repo. I'll make sure my local copy of the repo is up-to-date by pulling and merging the changes in master to my local repo, run any necessary database update scripts, then test locally. If something needs fixing, I'll fix it myself or ask the responsible developer to fix it. If things look good, then I'll log in to our staging server (which is actually on our live server, but uses a separate database and a non-publicly-accessible URL), pull the code from the GitHub repo to the repo there, update the database, and test again there. That way, any bugs which might happen on the live server but isn't happening to me on my local dev server can be caught.
If things still look good, then I'll tag the relevant commit in the repo with an applicable tag, like BETA-4
or v1.8
, on my local dev repo and push the tag. Then I'll log in to the live server, back up the database, pull the master branch from GitHub, and then use git checkout
to check out the tag I just created. That's the trick there; if you have a tag (other than HEAD
) checked out, then Git will keep the state of the repo to the files as of the commit that tag points to until you check out another tag. Then I run the update scripts on the live server, and there you go.
Git is a powerful tool, and all the people who try to tell you it's easy to use are oughtright liars. I highly recommend you get a good book on it if you're a newbie. Hell, I've been using it almost daily for almost two years now, and it still surprises me at times. O'Reilly's book is decent as usual, and I find SourceTree to be a nice OS X GUI app (you should of course learn to use the CLI interface, particularly so you can log into remote servers and do pulls and such via SSH, but a nice GUI can make tasks such as doing a commit in which you only commit some of the changed files in a repo much more pleasant).