256

When I run:

git status

I see this:

rebase in progress; onto 9c168a5
You are currently rebasing branch 'master' on '9c168a5'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working directory clean

When I do:

ls `git rev-parse --git-dir` | grep rebase || echo no rebase

I see: rebase-apply

I can't commit to origin.

git branch

Shows:

* (no branch, rebasing master)
  develop
  master

I'm stuck. I don't know what to do? Does it really take this long to rebase? git rebase --continue doesn't do anything. I don't have anything in git status.. I'm just waiting for the rebase. What can I do?

UDATE: This is the output of: git rebase --continue

Applying: no message
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

git add . has nothing.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Joseph Chambers
  • 3,698
  • 4
  • 22
  • 37

12 Answers12

433

Rebase doesn't happen in the background. "rebase in progress" means that you started a rebase, and the rebase got interrupted because of conflict. You have to resume the rebase (git rebase --continue) or abort it (git rebase --abort).

As the error message from git rebase --continue suggests, you asked git to apply a patch that results in an empty patch. Most likely, this means the patch was already applied and you want to drop it using git rebase --skip.

user1767754
  • 23,311
  • 18
  • 141
  • 164
Matthieu Moy
  • 15,151
  • 5
  • 38
  • 65
  • I updated the post to include git rebase --continue per your request. – Joseph Chambers Apr 27 '15 at 20:11
  • 3
    OK, then "it rebase --continue doesn't do anything" was inaccurate. You should have written "git rebase --continue errors out as follows ..." to get help. – Matthieu Moy Apr 30 '15 at 14:37
  • 3
    The documentation of this very badly, it keeps repeating that you 'git rebase --continue' and you will end up in an infinite way of saying that. – Jean-Paul Apr 18 '16 at 12:21
  • 10
    git rebase --skip did it! – Borzh Nov 03 '17 at 20:39
  • As this is a question for relative beginners (like me) i thought its worth mentioning all this talk of run this or that - requires opening a new terminal and going back into the repo...nothing would run in my instance of this issue without doing that, – DCX Nov 16 '17 at 00:27
  • `git rebase --continue` does not work. It does not *continue* anything. State remains the same `rebase in progress; onto ab262ab0` – Green Nov 11 '19 at 10:41
  • What exact error message do you get? Probably worth a separate question with details actually. – Matthieu Moy Nov 12 '19 at 07:00
  • git rebase --skip introduces even more conflicts which have been solved. This is really confusing. – Joe Apr 13 '23 at 16:17
75

If git rebase --abort doesnt work and you still get

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

Type:

git rebase --quit
Panda-313
  • 820
  • 5
  • 5
33
  • Step 1: Keep going git rebase --continue

  • Step 2: fix CONFLICTS then git add .

  • Back to step 1, now if it says no changes .. then run git rebase --skip and go back to step 1

  • If you just want to quit rebase run git rebase --abort

  • Once all changes are done run git commit -m "rebase complete" and you are done.


Note: If you don't know what's going on and just want to go back to where the repo was, then just do:

git rebase --abort

Read about rebase: git-rebase doc

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
  • The `--continue` didn't work, it told me nothing changed... Once I did a `--skip`, though, I could just `push`. I just don't understand that stuff. It's like each time I do totally random things until it works. – Alexis Wilke Aug 07 '20 at 00:42
  • 1
    @AlexisWilke Yes, you have to do a `--skip` when there are no changes so that you can continue rebase on the next commit from the main branch. What is actually happening is you are replaying all your changes (in current branch) on to the main branch so that you are upto date with the main branch and also have your changes placed after that. Go through: [git-scm rebasing](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) (go through only **The Basic Rebase** from the link and you should get a good idea on what is going on). – Ani Menon Aug 07 '20 at 05:22
  • My problem was that it had opened a Notepad window in which to put a commit message again, after resolving a merge conflict. This was obvious after `git rebase --continue` from a command line in the folder of my solution. Closing and saving that file resolved it. – Michael Foster Feb 24 '23 at 21:31
21

I got stuck in 'rebase status', I got

On branch master
Your branch is up to date with 'origin/master'.

You are currently rebasing.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean

but running git rebase --skip yielded error: could not read '.git/rebase-apply/head-name': No such file or directory.

Running rm -fr ".git/rebase-apply" helped.

Note: of course, do it only if you don't care about the rebase or if you're stuck on a previous rebase you don't want anymore.

wildeyes
  • 6,767
  • 5
  • 19
  • 37
7

You told your repository to rebase. It looks like you were on a commit (identified by SHA 9c168a5) and then did git rebase master or git pull --rebase master.

You are rebasing the branch master onto that commit. You can end the rebase via git rebase --abort. This would put back at the state that you were at before you started rebasing.

Schleis
  • 41,516
  • 7
  • 68
  • 87
  • I never do a `git rebase/pull --rebase master`. I often end up in this state... because of a conflict. I change a file, do a pull, restore my changes and the new patch is empty which hurts git's brain which then decides to enter this "rebase mode"... – Alexis Wilke Aug 12 '19 at 04:38
7

I got into this state recently. After resolving conflicts during a rebase, I committed my changes, rather than running git rebase --continue. This yields the same messages you saw when you ran your git status and git rebase --continue commands. I resolved the issue by running git rebase --abort, and then re-running the rebase. One could likely also skip the rebase, but I wasn't sure what state that would leave me in.

$ git rebase --continue
Applying: <commit message>
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

$ git status
rebase in progress; onto 4df0775
You are currently rebasing branch '<local-branch-name>' on '4df0775'.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working directory clean
jsears
  • 4,511
  • 2
  • 31
  • 36
  • In addition of `--abort` (+1), you now have `--quit` (http://stackoverflow.com/a/41363262/6309) – VonC Dec 28 '16 at 13:40
  • After fix the conflicts. then call git commit. do some other job, then call git commit again. If use this method git rebase --abort, all the work you are doing after commit conflict will be wished away. So be careful – Jin Sep 06 '19 at 05:48
0

I setup my git to autorebase on a git checkout

# in my ~/.gitconfig file
[branch]
    autosetupmerge = always
    autosetuprebase = always

Otherwise, it automatically merges when you switch between branches, which I think is the worst possible choice as the default.

However, this has a side effect, when I switch to a branch and then git cherry-pick <commit-id> I end up in this weird state every single time it has a conflict.

I actually have to abort the rebase, but first I fix the conflict, git add /path/to/file the file (another very strange way to resolve the conflict in this case?!), then do a git commit -i /path/to/file. Now I can abort the rebase:

git checkout <other-branch>
git cherry-pick <commit-id>
...edit-conflict(s)...
git add path/to/file
git commit -i path/to/file
git rebase --abort
git commit .
git push --force origin <other-branch>

The second git commit . seems to come from the abort. I'll fix my answer if I find out that I should abort the rebase sooner.

The --force on the push is required if you skip other commits and both branches are not smooth (both are missing commits from the other).

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
  • “Otherwise, it automatically merges when you switch between branches” — Um, no. Git doesn’t do any sort of merge or rebase when you switch branches. `autosetupmerge` has to do with how `git pull` is configured for new branches. – Marnen Laibow-Koser Jun 14 '18 at 06:16
  • At this time when I was fighting with that problem, it sure did some kind of merging of various code. My current setup seems to skip on that problem. There is also the problem of not having done a commit + push of your current branch before trying to switch. – Alexis Wilke Jun 15 '18 at 17:52
  • Git will tell you if your uncommitted changes would prevent switching branches, so there’s not much to worry about there, is there? Or are you talking about something else? – Marnen Laibow-Koser Jun 15 '18 at 18:16
0

Mine was an error that popped up from BitBucket. Ran git am --skip fixed it.

Kevin Aung
  • 803
  • 6
  • 12
0

I was facing the same issue, In my case when I try to rebase I got conflicts, and once I resolved all the conflicts and try to add a commit message but it show this error in my client editor (VS Code)

enter image description here

To resolve this we need to fire this command git commit -C HEAD@{1}

  • git commit -C HEAD@{1} It will point to the commit you were at before you did rebase

Sometimes in VS code still It showing rebase in progress, To solve that you need to fire this command rm -rf .git/REBASE_HEAD

  • rm -rf .git/REBASE_HEAD It will remove "REBASE_HEAD" from your local
Neel Rathod
  • 2,013
  • 12
  • 28
0

I checked out a new branch from the HEAD rebase. That worked.

Sai Prasad
  • 131
  • 9
0

My solution to wipe out a messy interactive rebase was:

   > git clean -xfd
   > git reset --hard branch_being_rebased
   > git rebase --abort

Warning git clean -xfd wipes out any uncommitted or untracked file under your repo

pasx
  • 2,718
  • 1
  • 34
  • 26
-1

Another option to ABORT / SKIP / CONTINUE from IDE

VCS > Git > Abort Rebasing

enter image description here

Prabs
  • 4,923
  • 6
  • 38
  • 59