2

I resolved huge merge-conflict after rebase and mistakenly runned git commit --amend instead of git commit.
Now git thinks that previous commit has all my changes. Is there a way to undo git commit --amend and get in index all my changes after merging?

Paul
  • 6,641
  • 8
  • 41
  • 56

2 Answers2

4

Start with taking a copy of you repo in case I've written anything wrong in my instructions.

You've amended your commit so the original un-amended commit is still somewhere in the tree although no branch points at it.

You can probably find it back using one of the following:

git fsck --lost-found
git reflog

Then you can reset back to this commit. Reseting soft will only make you point at that commit and will leave your files unchanged, reseting hard will wipe all changes (and the merge conflicts you were resolving):

git reset [--hard|--soft] <your_commit_hash>
Thibault D.
  • 10,041
  • 3
  • 25
  • 56
  • 2
    `git reflog` and `git reset --soft %mychangehash%` returned my changes to index. Thanks a lot! You saved something about 4 hours for me! :) – Paul Jun 09 '16 at 11:02
1

do git revert for further assistance checkout: https://www.atlassian.com/git/tutorials/undoing-changes/git-revert

s_user
  • 586
  • 2
  • 8
  • 19