So you have the following situation:
- You have a branch locally
- You are working on this branch, meaning that you have uncommited changes in your working folder
- You have commits on this branch locally, that you haven't pushed
- Someone else have made commits on this branch, which they have pushed (which means your local branch is out of date)
- You did a
git pull
which attempted to merge the commits from the upstream with your local commits, but failed and left you with a merge conflict
- You now have a working folder that has both the changes you had not yet committed, as well as merge conflict changes from the failed merge
The thing is, if step 5 would've ended up touching files you had changed locally but not yet committed, the merge would never have been attempted. Let me rewrite that, since git pull
attempted to merge, the changes from the commits that it tried to merge does not involve the files you have uncommitted changes to.
So all you have to do is this:
- Make a complete backup of your working folder and repository, and experiment on the copy (I don't want to be responsible for adding more problems)
Execute this command:
git merge --abort
This should restore your branch to its previous state, including the working folder. Any files you had uncommitted changes to before git pull
should be left as-is, since the merge never involved them anyway.