Is there a way I can undo a auto-merge of one file that has been changed instead of the whole branch in Git?
I want to undo this merge:
Auto-mergi
When you do:
git reset HEAD~1 public/stylesheet/application.css
... that changes the version of your file in the index (i.e. the staged version) to the version in HEAD~1
- your working copy remains the same. The current documentation explains this as:
This form resets the index entries for all
to their state at
If you do:
git checkout HEAD~1 -- public/stylesheet/application.css
... that will change both the working copy and the staged version to the version from HEAD~1
. The --
is there for safety, just in case you have file name that can also be understood as a commit.
Now that you're got that change staged, you could amend the merge commit with:
git commit --amend
... which is fair enough as long has you haven't pushed the merge anywhere, since the merge will still just have changes from one branch or the other.