Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a remote git repo that we normally deploy from using git push on our dev server then git pull on on our live servers to get the latest pushed version of the repo.

But if we have committed and pushed a few revisions (without a git pull on the live servers) how can we do a git pull that is referring to the older commit that we want?

i.e. something like git pull -r 3ef0dedda699f56dc1062b5dcc2c59f7ad93ede4

share|improve this question

3 Answers 3

up vote 17 down vote accepted

Once you've pulled the repository you should be able to go:

git checkout 3ef0d...
share|improve this answer
Nice, this worked perfectly. Also noticed that if I want to get back in sync for future pulls I need to specify the remote server when doing the next pull (i.e. git pull server:repo vs the regular git pull) –  dlrust Feb 26 '10 at 19:01

If some process on your live server immediately accesses the just-pulled content (i.e. you cannot work with git checkout 3ef0d after pull), you should consider tagging the version you want to deploy in production and specifically checkout that tag on production, so that pulling does not immediately change your working directory. Otherwise you'd risk somebody pushing just prior to your pull.

share|improve this answer

Note that a git pull git checkout my-old-commit now leaves you in a DETACHED HEAD state - effectively you're sending future commits in this repository down a new commit path. For a deployment repo this is not a major issue, since the only commits should be ones already committed correctly before being pulled.

However, its sometimes useful to check that the commit markers (head,tags,remotes) look identical to the master repo. To fix this following your checkout: git reset - reattaches the head git fetch - syncs the markers for remotes [this may be git version dependent - admittedly our environment is still on 1.7... so might no longer be required YMMV]

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.