Reputation: 5647
Please note, before indicating the question as a duplicate, that I have read the answer here but, with the solution proposed, I will delete all the uncommitted changes.
Problem:
I have developed new features using a dedicated branch. In the meanwhile, the master branch continued to be developed by others. I decided to do a git pull
in order to rebase my code to the new one. However, there were conflicts: somebody has improved the code on the remote repo.
Question:
Upvotes: 1
Views: 153
Reputation: 52151
If the rebase did start although you had local modifications, chances are you have the "autostash" option turned on.
Otherwise, the rebase would not have started at all.
Check the value of this config parameter :
git config --get rebase.autostash
You should see true
You can run git rebase --abort
to cancel the rebase.
You should see a line :
Applied autostash.
which indicates that your unstaged changes have been restored.
Upvotes: 2
Reputation: 391634
So you have the following situation:
git pull
which attempted to merge the commits from the upstream with your local commits, but failed and left you with a merge conflictThe 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:
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.
Upvotes: 2