Kir
Kir

Reputation: 8111

Cannot rebase onto multiple branches

When I'm trying to pull and rebase single branch, git is failing with Cannot rebase onto multiple branches.

I've browsed existing questions and all of them suggest specifying the branch to avoid the error. In my case it's still failing:

$ git pull --rebase origin master
From github.com:xxx/yyy
 * branch            master     -> FETCH_HEAD
Cannot rebase onto multiple branches

Running the command for 2-3 times helps and the repository gets pulled.

My git config:

[color]
        ui = true
[core]
        pager = less -r
        autocrlf = input
        excludesfile = /Users/kir/.gitignore_global
        editor = /usr/bin/vim
[push]
        default = simple
[filter "lfs"]
        clean = git-lfs clean %f
        smudge = git-lfs smudge %f
        required = true

Git version: 2.7.2 (latest from Brew)

Upvotes: 6

Views: 6859

Answers (2)

HanleyLee
HanleyLee

Reputation: 121

I get same error in my custom bash script while git pull origin branch --rebase

My solution is using git fetch --all --prune && git rebase origin/branch instead of git pull origin branch --rebase

Upvotes: 0

CodeWizard
CodeWizard

Reputation: 142572

Try to set the rebase at the end of the command instead as the first flag:

git pull origin branch --rebase

If this is still doesnt work split it into 2 commands (pull = fetch + merge).

# fetch all the remote data
git fetch --all --prune

# no execute a merge command
git merge origin/branch --rebase

Upvotes: 15

Related Questions