Reputation: 4405
I am working in a branch and I pulled rebase from remote and I got some merge conflicts.
I resolved the conflicts but before git add
and git rebase --continue
I got distracted and continue doing actual work.
Now I am in the state that my working tree is fine code-wise with the old conflicts resolved and new code present but git status
shows You are currently rebasing branch...
What can I do to fix this and not mess up my work?
Upvotes: 1
Views: 39
Reputation: 488053
It is, unfortunately, rather hard to disentangle things at this point.
The rebase is still ongoing, and as far as Git knows, you are still fixing up the copy of the conflicted commit. Whatever you've done since then must therefore be part of fixing up the conflict. Remember, Git doesn't actually store differences. It just stores full snapshots. You can, if wish, replace every file with a whole new version: Git doesn't care, it just takes a snapshot. Hence if you continue now, you'll combine your changes that you didn't mean to include as part of the fixing-up, into what Git thinks is still the fixing-up.
(That might not be awful! If it's OK, consider doing that. But assuming it's not OK, read on.)
If your rebase-so-far was not difficult, I'd suggest just moving (or copying) everything in your work-tree as it is right now into some other directory outside the repository entirely. That way you have the combination of "what you did to fix conflicts" and "what you did since then" available outside this Git entirely. Then, having done that, you can:
git rebase --abort
which will stop the ongoing rebase and put everything back to the way it was before you even started the rebase. All your work is now gone from the repository, which is why you saved it outside the repository, where it still exists.
Then, redo the rebase that git pull
started, which is probably1 as simple as:
git rebase
This will get the same conflicts, which you'll have to fix again, but this time you can remember to git add
and git rebase --continue
afterward. You can peek at your saved work (outside the repository) to see how you fixed things up last time.
Once the rebase is truly complete, you can use git diff
against the outside files, or just copy the outside files back inside and use git diff
.
(There are ways to do all of this while storing the files in Git, on temporary branches or using git stash
, but I would not recommend that.)
1This depends on exactly what you used for your git pull --rebase
command. If you just ran git pull --rebase
, you can just run git rebase
. If you had additional arguments, you might need git rebase FETCH_HEAD
.
Upvotes: 1