Skip to contentSkip to conversation

git pull merges current branch even when <dst> is specified

DISCUSSION Tom Lambda 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Tom Lambda

author
#0 lore raw

If I am in 'master' and 'bugfix' is a remote branch in 'repo' which I do not have locally yet, running:

git pull repo bugfix:bugfix

creates a new local branch 'bugfix' equals to 'repo/bugfix' as expected. However, it also merges 'bugfix' into 'master', that surprises me since I explicitly specify that <dst> is 'bugfix'.

I know that I can get what I want by running:

git fetch repo bugfix:bugfix

But the git-pull behavior looks odd to me. I thought that <dst> was the current branch by default and it could be overridden by specifying it in the command line.

Thank you,
Tom

Signature · 2 lines
View this message in context: http://n2.nabble.com/git-pull-merges-current-branch-even-when-%3Cdst%3E-is-specified-tp3149948p3149948.html
Sent from the git mailing list archive at Nabble.com.
#1 lore raw

Tom Lambda venit, vidit, dixit 24.06.2009 18:47:

Quoted 10 lines

If I am in 'master' and 'bugfix' is a remote branch in 'repo' which I do not have locally yet, running:

git pull repo bugfix:bugfix

creates a new local branch 'bugfix' equals to 'repo/bugfix' as expected. However, it also merges 'bugfix' into 'master', that surprises me since I explicitly specify that <dst> is 'bugfix'.

Quoted 7 lines

I know that I can get what I want by running:

git fetch repo bugfix:bugfix

But the git-pull behavior looks odd to me. I thought that <dst> was the current branch by default and it could be overridden by specifying it in the command line.

Well, the first line of git-pull's man page says:

Runs git-fetch with the given parameters, and calls git-merge to merge the retrieved head(s) into the current branch.

So I can't help but call your surprise somewhat unjustified ;)

Michael

#2 lore raw

Hi,

Quoted 15 lines · Michael J Gruber

Tom Lambda venit, vidit, dixit 24.06.2009 18:47:

Quoted 14 lines

If I am in 'master' and 'bugfix' is a remote branch in 'repo' which I do not have locally yet, running:

git pull repo bugfix:bugfix

creates a new local branch 'bugfix' equals to 'repo/bugfix' as expected. However, it also merges 'bugfix' into 'master', that surprises me since I explicitly specify that <dst> is 'bugfix'.

I know that I can get what I want by running:

git fetch repo bugfix:bugfix

Quoted 8 lines
Quoted 3 lines

But the git-pull behavior looks odd to me. I thought that <dst> was the current branch by default and it could be overridden by specifying it in the command line.

Well, the first line of git-pull's man page says:

Runs git-fetch with the given parameters, and calls git-merge to merge the retrieved head(s) into the current branch.

To explain why this is so: Merging is an operation that requires a working directory, as merge conflicts can happen. That is why merging is only possible locally, and only into the current branch.

Ciao,
Dscho

author
#3 lore raw

Thank you for the explanation.

So specifying :<dst> in git-pull does not seem that useful now to me, since one has to checkout the <dst> branch anyway to keep other branches unaltered.

Thanks again,
Tom

Quoted 7 lines · Johannes Schindelin

To explain why this is so: Merging is an operation that requires a working directory, as merge conflicts can happen. That is why merging is only possible locally, and only into the current branch.

Signature · 2 lines
View this message in context: http://n2.nabble.com/git-pull-merges-current-branch-even-when-%3Cdst%3E-is-specified-tp3149948p3155010.html
Sent from the git mailing list archive at Nabble.com.