I have been working on dev branch, made a couple of commits and pushes, now I merged this branch into master. I want to make a git pull
on the production server, but what if something won't work after that? Is there a way to revert the changes and come back to where it was before git pull
?
Asked
Active
Viewed 42 times
0

khernik
- 2,059
- 2
- 26
- 51
-
1Assuming you have no unstaged changes, note down the commit and just reset to that commit if you need to? – Holloway Aug 11 '15 at 12:19
-
As an aside, there are deployment solutions that solve this and other problems, such as Capistrano, Fabric, and others. http://williamdurand.fr/2012/02/25/deploying-with-git/ – raylu Aug 11 '15 at 23:30
2 Answers
0
Take a look at answer for this question: how to reset to a specific commit?. I think that's what you are trying to achieve.
0
If you did a non-fastforward merge of dev
into master
(i.e. you created a merge commit "Merge dev into master"), you can reset to the commit before the merge using git reset --hard HEAD^
. If you did a fast-forward merge (i.e. there is no "Merge dev into master" commit) you can reset to the state before the pull using git reset --hard ORIG_HEAD
, assuming you did nothing else after the pull. The latter can be used even in the first case, but it may be more intuitive to use git reset --hard HEAD^
.

jsageryd
- 4,234
- 21
- 34