Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git rebase origin" vs."git rebase origin/master"

Tags:

git

git-rebase

I don't get the difference between git rebase origin and git rebase origin/master. In my case I cloned a git repository twice. In the first clone I have to use git rebase origin and in the other clone I must use git rebase origin/master.

An example: http://paste.dennis-boldt.de/2011/05/11/git-rebase

like image 726
Dennis Avatar asked May 11 '11 11:05

Dennis


2 Answers

git rebase origin means "rebase from the tracking branch of origin", while git rebase origin/master means "rebase from the branch master of origin"

You must have a tracking branch in ~/Desktop/test, which means that git rebase origin knows which branch of origin to rebase with. If no tracking branch exists (in the case of ~/Desktop/fallstudie), git doesn't know which branch of origin it must take, and fails.

To fix this, you can make the branch track origin/master with:

git branch --set-upstream-to=origin/master  

Or, if master isn't the currently checked-out branch:

git branch --set-upstream-to=origin/master master 
like image 199
CharlesB Avatar answered Sep 25 '22 04:09

CharlesB


Here's a better option:

git remote set-head -a origin 

From the documentation:

With -a, the remote is queried to determine its HEAD, then $GIT_DIR/remotes//HEAD is set to the same branch. e.g., if the remote HEAD is pointed at next, "git remote set-head origin -a" will set $GIT_DIR/refs/remotes/origin/HEAD to refs/remotes/origin/next. This will only work if refs/remotes/origin/next already exists; if not it must be fetched first.

This has actually been around quite a while (since v1.6.3); not sure how I missed it!

like image 22
Cascabel Avatar answered Sep 25 '22 04:09

Cascabel