I just did git pull instead of git fetch. I was in a local branch that I didn't want to merge with origin/master. Moreover, I had some uncommited changes.
Now my staging area is full of changes from origin/master I'd like to revert, but if I unstage them, they will mix with my uncommited changes in unstaged.
How can I remedy this situation?
I am assuming that the whole mess of changes are due to conflicts from your merge. What I would suggest to do is.
git stash your uncommitted changes so that we don't lose them.git log -3, this will show your merge commit along with 2 previous commits. In the merge commit you will see 2 SHAS. One is the latest commit from origin/master and the other the last commit on your branch.git reset --hard <SHA of YOUR last commit> This will reset your branch to before you merged and get rid of all the commits/changes that you brought in from master.git stash pop to get your uncommitted changes back on to your branch.Because your changes are all on your local branch, you can modify history to get things back to a state that you want without any problems. If there are any staged files that you actually want do a git reset -- <filenames> to unstage them and then follow the above steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With