Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git pull --rebase" leads to "Cannot rebase onto multiple branches"

So, my work environment has precisely one branch with a remote companion on Github. I'm trying to do git pull --rebase in order to prevent git push from creating merge commit messages that don't provide new information to others working on this project and just gum up the works. But when I try that, it gives me this:

From https://github.com/our_profile/our_repository  * branch            HEAD        -> FETCH_HEAD Cannot rebase onto multiple branches 

And the pull aborts. Calling git branch informs me that I have only one branch on my local machine, so what's going on?

like image 751
bourgtai Avatar asked Apr 02 '12 21:04

bourgtai


People also ask

Can I rebase multiple branches?

How to stack up branches on top of each other and keep them all updated using rebase. If you have only one branch, the previous way is enough to make sure your branch is always updated with the latest changes in master. The problem starts when you have multiple branches depending on each other.

What does pull rebase do?

Git pull rebase is a method of combining your local unpublished changes with the latest published changes on your remote. Let's say you have a local copy of your project's main branch with unpublished changes, and that branch is one commit behind the origin/main branch.

Is it better to pull or rebase?

It is best practice to always rebase your local commits when you pull before pushing them. As nobody knows your commits yet, nobody will be confused when they are rebased but the additional commit of a merge would be unnecessarily confusing.

What is the difference between pull merge and pull rebase?

Merging is a safe option that preserves the entire history of your repository, while rebasing creates a linear history by moving your feature branch onto the tip of main .


1 Answers

Try specifying exactly what remote branch you want to pull:

git pull --rebase origin branch 

Alternatively you can also git fetch all changes from the remote repository first, and then rebase manually:

git rebase origin/branch 
like image 194
poke Avatar answered Sep 18 '22 08:09

poke