rebase in progress. Cannot commit. How to proceed or stop (abort)?

后端 未结 9 1266
鱼传尺愫
鱼传尺愫 2020-12-12 12:46

When I run:

git status

I see this:

rebase in progress; onto 9c168a5
You are currently rebasing branch \'master\' on \'9c1         


        
相关标签:
9条回答
  • 2020-12-12 12:55
    • 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

    0 讨论(0)
  • 2020-12-12 12:55

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

    0 讨论(0)
  • 2020-12-12 12:57

    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.

    0 讨论(0)
  • 2020-12-12 13:02

    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
    
    0 讨论(0)
  • 2020-12-12 13:06

    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).

    0 讨论(0)
  • 2020-12-12 13:09

    Another option to ABORT / SKIP / CONTINUE from IDE

    VCS > Git > Abort Rebasing

    0 讨论(0)
提交回复
热议问题