fatal: Could not open file .git/rebase-merge/done for reading: No such file or directory

GitGithub

Git Problem Overview


I was going to do a rebase to delete my last commit but I didn't want to finish so I exited. (I realize this probably was not the best way to go about it, but it's done) I guess I did it wrong because I am getting the error: fatal: Could not open file .git/rebase-merge/done for reading: No such file or directory every time I run git status. How do I get rid of this error so I can continue making commits? Can I just delete the file? If I can delete it, how would I do that?

Git Solutions


Solution 1 - Git

Before you try the following, make sure you stash or commit any uncommitted changes first, or you will lose them irrevocably.

Then try to do a git rebase --abort.

Solution 2 - Git

Stash or commit didn't work for me, I just created the files that git was complaining about until it worked!

$ git rebase --abort
error: could not read '.git/rebase-apply/head-name': No such file or directory

echo "master" > .git/rebase-apply/head-name

$ git rebase --abort
error: could not read '.git/rebase-apply/onto': No such file or directory

$ echo "develop" > .git/rebase-apply/onto

$ git rebase --abort
error: could not read '.git/rebase-apply/head': No such file or directory

$ echo "develop" > .git/rebase-apply/head

After which git rebase --abort worked. The branch names you are putting in those files needs to exists, and in my case I didn't care about my local changes, but obviously be careful with this if you do.

Solution 3 - Git

DavidN's solution to abort the rebase is great as long as you don't have any unstaged changes since the last rebase going south!

If you wrote code after the rebase attempt, ignoring the could not open file .git/rebase-merge/done message,

then your best bet is to do

git stash

to save your local changes and only then abort the rebase.

I am sure this is one of those stackoverflow questions, where people who are eager to solve their problem without considering the implications, will just run the abort command and regret it soon after.

Solution 4 - Git

I've just done:

git add .
git commit -m "change inter rebase"

and then could continue:

git rebase --continue

No

git stash 
git rebase --abort 

needed.

Solution 5 - Git

For some one doing this from within Visual Studio Code, close the running terminal/shell and then run git rebase --quit

Doing this will solve the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndreaView Question on Stackoverflow
Solution 1 - GitDavidNView Answer on Stackoverflow
Solution 2 - GitStefanoView Answer on Stackoverflow
Solution 3 - GitDimitris BaltasView Answer on Stackoverflow
Solution 4 - GitRobert OsparaView Answer on Stackoverflow
Solution 5 - GitGruView Answer on Stackoverflow