Git reset current rebase
I’ve been doing a rebase. I’ve worked on fixing some conflicts but I’ve ended up going in the wrong direction and now I just want to start again fixing these conflicts.
I’d like to reset the rebase, so that I’m still rebasing the current commit but the working copy has been reset to when the commit was flagged up with conflicts in the first place.
How can I reset a rebase on the current commit?
3 Solutions collect form web for “Git reset current rebase”
If you just want to redo a merge for a specific file, all you need to do is:
git checkout -m <file>
If you want to redo the whole commit, here’s how I do it (there’s probably a better way of doing this):
- There’s a conflict during the rebase
- I mess up the conflict resolution
I run a
git statuswhich, as of Git 2.0.0, gives me something like this (only if you are doing an interactive rebase):
interactive rebase in progress; onto 14ed389 Last command done (1 command done): pick db2511c Modify file Next command to do (1 remaining command): pick d1c2037 Modify file one more time (use "git rebase --edit-todo" to view and edit) You are currently rebasing branch 'other' on '14ed389'. (fix conflicts and then run "git rebase --continue") (use "git rebase --skip" to skip this patch) (use "git rebase --abort" to check out the original branch) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add <file>..." to mark resolution) both modified: file.txt
- I copy the line for the command the rebase is currently executing:
pick db2511c Modify file
- I run
git rebase --edit-todoand paste the line onto the top of the file
- I run
git rebase --skip
If you are in between your rebase, you can do
git rebase --abort
If You have had multiple commits editing same files on both branches and, during rebasing decided that want to preserve some work, not drop all changes already made (
git rebase --abort) then I guess You’ll need to look into directory
.git/rebase-apply and check
patch file. It contains all changes made during rebasing. You’d manually apply this patch after doing
git rebase --abort.