Is there any way to revert or undo git pull so that my source/repos will come to old state that was before doing git pull ? I want to do this because it merged some files which I didn't want to do so, but only merge other remaining files. So, I want to get those files back, is that possible ? Thanks :)
EDIT I want to undo git merge for clarification.
After seeing some answers, I did this
git reflog
bb3139b... HEAD@{0}: pull : Fast forward
01b34fa... HEAD@{1}: clone: from ...name...
Now, what should I do ? Doing git reset --hard is OK ? I dont want to screw it again, so asking for detailed steps ?
EDIT problem solved
Solution suggested by jkp worked.
-
git pullwill do two things: it does agit fetchand then agit mergewhere it merges branches that have been setup to be merged in your config.So what you want to do is to undo the merge (undoing the fetch doesn't make a lot of sense and shouldn't be necessary).
To do that you can try using
git reset --hardto reset to a previous state. Use the git-reflog command to find the SHA-1 of the previous state and then reset to it.seg.server.fault : Thanks, you saved my day :)Jefromi : An excellent way to pick the previous state, instead of using git-reflog and copying hashes, is to use a shortcut like `master@{1}`, which is the previous position of `master`, `master@{"5 minutes ago"}`, or `master@{14:30}`. Full details on specifying revisions in this way can be found in `man git-rev-parse`, in the section called "specifying revisions".Jakub Narębski : In this case ORIG\_HEAD should also work ("git reset --hard ORIG\_HEAD")jkp : @Jelfromi: thanks for that tip, I wasn't aware you could be so verbose about revisions. I knew about picking revisions relative to HEAD, but when the question was posed I didn't knowhow far back in time he wanted to go.apphacker : Saved my ass too. I really hate git. -
If you have gitk (try running "gitk --all from your git command line"), it's simple. Just run it, select the commit you want to rollback to (right-click), and select "Reset master branch to here". If you have no uncommited changes, chose the "hard" option.
seg.server.fault : No, I havent commited anything just did git pull only.Don Branson : git-pull autocommits.seg.server.fault : Thanks, it worked now.
0 comments:
Post a Comment