Git rollback to previous checkout
I've cloned some project from github, to my project, all works good, I'm happy.
But after some git pulls I receive some conflicts in my project with new commits of upstream project.
I want to rollback to previous checkout, but i don't know which stable checkout was previous in my project.
How I can know it and rollback to previous stable (for me) project checkout? I understand that in perspective more correct way to fix my conflicts with upstream repo, but sometimes i just need rollback to previous version, to get time for fixing problem.
If you have a command/script you can execute and which would illustrate a "stable point" (ie something working, as opposed to the current state where it is not working), then you can consider a git bisect
command.
See "How to use git bisect?".
That would help you isolate the last commit where "it was working".
git reflog
should tell you the order of operations, most recent first. Look for the commit ID that was operated on before your first pull/merge; checkout
or reset --hard
to that.
Have you already commited the merge? If not, just git reset --hard
and you're back to the state before you issued git pull
. Otherwise, git reset --hard HEAD^
(if the merge was the last commit) does the trick, since git will by default always pick the first parent of a merge commit, which is your branch. If in doubt, you can always use eg gitk
to inspect the situation and find the last commit on your branch, copy its SHA1 hash and revert to that.
上一篇: 做完git pull后找不到我的提交
下一篇: Git回滚到之前的结帐