1

I did a git rebase HEAD~3 to edit some commit messages, however when I entered the interactive mode, it showed more than my last 3 commit messages. It showed a bunch of other commits. Every time I went on each of these other commits, it warned of a MERGE_CONFLICT and I just did git rebase --skip since these weren't my commits and they were old commits as well. I kept doing git rebase --skip until the rebase completed. I then did git status and it said my branch has diverged from my last commit. I pulled from my last commit, now I have a bunch of conflicts. How do I UNDO everything BEFORE I started this REBASE. I just want to restore my branch to the last commit I pushed. After the rebase was complete, I did not force push yet so everything is still local. I want to undo all this.

henhen
  • 1,038
  • 3
  • 18
  • 36

1 Answers1

1

Do hard reset with your last commit you want to go back:

$ git log  # copy the commit hash
$ git reset --hard <commit-hash>

Or, if you want local history same as remote branch then do hard reset local branch with remote branch:

say, local branch name is b1:

$ git fetch
$ git reset --hard origin/b1 
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
  • I think doing that would undo all my past 3 commits to this branch? Would it be better to git reset hard with commit hash? – henhen Feb 11 '19 at 07:45