threads / discuss / 19917

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

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

## tl;dr

4 messages between Jun 24, 2009 and Jun 25, 2009.

replies: 3people: 3as markdown or json

Tom Lambda· Jun 24, 2009, 16:47 UTC · lore

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

-- 
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.
Michael J Gruber· Jun 25, 2009, 08:52 UTC · re: Tom Lambda · lore

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

Tom Lambda venit, vidit, dixit 24.06.2009 18:47:
Show 17 quoted 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
> 
> 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
Johannes Schindelin· Jun 25, 2009, 09:44 UTC · re: Michael J Gruber · lore

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

Hi,
On Thu, 25 Jun 2009, Michael J Gruber wrote:
Show 23 quoted lines
> Tom Lambda venit, vidit, dixit 24.06.2009 18:47:
> > 
> > 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.
> 
> 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

Tom Lambda· Jun 25, 2009, 13:28 UTC · re: Johannes Schindelin · lore

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

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

Johannes Schindelin wrote:
Show 7 quoted lines
> 
> 
> 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.
> 
> 
-- 
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.

← back to recent threads