How to category Design category Development category News category

Staging with Git

We use a branching model which is based on each developer having their own "dev" branch, a "proofing" branch to collectively test ideas, a "staging" branch for testing the next feature to go to the "live" branch. In this article our remote is called "origin".

This means that the staging and proofing branches need to be reset, from time to time. This is particularly likely in the staging branch which is reset every time a new feature is earmarked for release to a live branch.

To reset your local staging branch you first need to make it equivalent to live – this is done by running the following –

git checkout live

git update-ref refs/heads/staging refs/heads/live

That checks-out the live branch and points your local staging to your local live (which you should make sure is up-to-date first).

You will have to force your branch back to the remote however, since your now potentially behind the old staging to force the remote update run –

git push origin +staging

This does mean that when staging features to the staging branch you should either routinely reset the stating branch to live using the above (this is the preferred method) or as inevitably happens you need to stage more than one thing on staging you should always check that your not ahead of staging when you pull. If your ahead of staging on a pull then it's likely it has been reset!

To reset your local staging in the event that your branch is ahead of the remote you can easily reset your local branch staging branch by running –

git checkout staging

git reset --hard origin/staging

This could of course be automated… *ant*



Craig enjoys producing usable and friendly sites that look great and function well. He often also experiments with workflow automation and owns and runs web-engineer.

Comments are closed.