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

4 messages from 2009-06-24 to 2009-06-25. Participants: Tom Lambda, Michael J Gruber, Johannes Schindelin.
Thread: https://gitlist.dev/t/19917

## Tom Lambda, 2009-06-24 16:47

Subject: git pull merges current branch even when <dst> is specified
Message-ID: <1245862052581-3149948.post@n2.nabble.com>
URL: https://gitlist.dev/e/1245862052581-3149948.post%40n2.nabble.com

```

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, 2009-06-25 08:52

Subject: Re: git pull merges current branch even when <dst> is specified
Message-ID: <4A433AC8.4040702@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4A433AC8.4040702%40drmicha.warpmail.net
In-Reply-To: <1245862052581-3149948.post@n2.nabble.com>

```
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.

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

Michael

```

## Johannes Schindelin, 2009-06-25 09:44

Subject: Re: git pull merges current branch even when <dst> is specified
Message-ID: <alpine.DEB.1.00.0906251142550.5365@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0906251142550.5365%40intel-tinevez-2-302
In-Reply-To: <4A433AC8.4040702@drmicha.warpmail.net>

```
Hi,

On Thu, 25 Jun 2009, Michael J Gruber wrote:

> 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, 2009-06-25 13:28

Subject: Re: git pull merges current branch even when <dst> is specified
Message-ID: <1245936518805-3155010.post@n2.nabble.com>
URL: https://gitlist.dev/e/1245936518805-3155010.post%40n2.nabble.com
In-Reply-To: <alpine.DEB.1.00.0906251142550.5365@intel-tinevez-2-302>

```

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:
> 
> 
> 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.

```
