# Strange branch merging.

6 messages from 2009-02-12 to 2009-02-12. Participants: Adam Panayis, Pieter de Bie, Sitaram Chamarty.
Thread: https://gitlist.dev/t/17743

## Adam Panayis, 2009-02-12 11:52

Subject: Strange branch merging.
Message-ID: <49940D93.6000204@movency.com>
URL: https://gitlist.dev/e/49940D93.6000204%40movency.com

```
Hi, I have just started using git and am having  a problem with 2 
branches appearing merged.

I have a local machine, on this I have 2 branches. The master and one 
named blah. My git repository is in the following location: /git/.git/

I have made changes to a file on the blah branch and committed these 
changes.

I checkout the master branch and as expected the changes are no longer 
there. I flip back to blah and I can see my changes. So far so good.

I then, on a remote machine use the pull command, the remote machine 
shows only the master branch as I have not asked it to pull blah. The 
command I use is as follows: git pull -v ssh://user@machine one/git/.git/

Once this is done I double check my branches and it shows I still only 
have the master. Perfect. However, when I check the file I edited on my 
local machine on the blah branch, the changes are there.

Am I fundamentally misunderstanding the correct usage of git? Is this 
result expected?

Thanks

```

## Pieter de Bie, 2009-02-12 12:27

Subject: Re: Strange branch merging.
Message-ID: <E65A809A-65AD-4755-8AA7-32AA11C9AB5A@frim.nl>
URL: https://gitlist.dev/e/E65A809A-65AD-4755-8AA7-32AA11C9AB5A%40frim.nl
In-Reply-To: <49940D93.6000204@movency.com>

```

On Feb 12, 2009, at 11:52 AM, Adam Panayis wrote:

> Once this is done I double check my branches and it shows I still  
> only have the master. Perfect. However, when I check the file I  
> edited on my local machine on the blah branch, the changes are there.
>
> Am I fundamentally misunderstanding the correct usage of git? Is  
> this result expected?

Yes, git pull will never change anything on the remote side. You  
should use 'git push' for that. But, you shouldn't push to repository  
with a working directory unless you know what you're doing -- read http://git.or.cz/gitwiki/GitFaq#non-bare 
  for that.

- Pieter

```

## Adam Panayis, 2009-02-12 12:40

Subject: Re: Strange branch merging.
Message-ID: <499418A4.9060401@movency.com>
URL: https://gitlist.dev/e/499418A4.9060401%40movency.com
In-Reply-To: <E65A809A-65AD-4755-8AA7-32AA11C9AB5A@frim.nl>

```
Pieter, thanks for your advice.

I am never using the push command here.

Box A has branches master and blah.
On Box B I just want to pull branch master.

When I try to do that on box B I get the master branch from box A but I 
get the changes made to branch blah on box A.

I do not understand why, on box B, the master branch is showing changes 
made to the blah branch on box A. (Yet on box A the changes to the blah 
branch are not shown in the master)

Apologies for my babbling.

Adam

Pieter de Bie wrote:
>
> On Feb 12, 2009, at 11:52 AM, Adam Panayis wrote:
>
>> Once this is done I double check my branches and it shows I still 
>> only have the master. Perfect. However, when I check the file I 
>> edited on my local machine on the blah branch, the changes are there.
>>
>> Am I fundamentally misunderstanding the correct usage of git? Is this 
>> result expected?
>
> Yes, git pull will never change anything on the remote side. You 
> should use 'git push' for that. But, you shouldn't push to repository 
> with a working directory unless you know what you're doing -- read 
> http://git.or.cz/gitwiki/GitFaq#non-bare for that.
>
> - Pieter

```

## Pieter de Bie, 2009-02-12 12:42

Subject: Re: Strange branch merging.
Message-ID: <FADBCA93-6742-43E8-A4A6-0090FBFF8BAB@frim.nl>
URL: https://gitlist.dev/e/FADBCA93-6742-43E8-A4A6-0090FBFF8BAB%40frim.nl
In-Reply-To: <499418A4.9060401@movency.com>

```
Hey,

[ Please don't top-post here, it makes following the discussion harder ]

On Feb 12, 2009, at 12:40 PM, Adam Panayis wrote:
> When I try to do that on box B I get the master branch from box A  
> but I get the changes made to branch blah on box A.
>
> I do not understand why, on box B, the master branch is showing  
> changes made to the blah branch on box A. (Yet on box A the changes  
> to the blah branch are not shown in the master)

You probably pulled in the 'blah' branch rather than the 'master'  
branch because that was
the branch that is checked out on box A. You can verify this by  
looking at 'git log' and
see that the commit on the blah branch is also there. To pull the  
master branch, specify
it explicitly, like this:

	git pull boxA:path/to/repo master

- Pieter

```

## Adam Panayis, 2009-02-12 12:59

Subject: Re: Strange branch merging.
Message-ID: <49941D4C.80502@movency.com>
URL: https://gitlist.dev/e/49941D4C.80502%40movency.com
In-Reply-To: <FADBCA93-6742-43E8-A4A6-0090FBFF8BAB@frim.nl>

```
Pieter de Bie wrote:
> Hey,
>
> [ Please don't top-post here, it makes following the discussion harder ]
>
> On Feb 12, 2009, at 12:40 PM, Adam Panayis wrote:
>> When I try to do that on box B I get the master branch from box A but 
>> I get the changes made to branch blah on box A.
>>
>> I do not understand why, on box B, the master branch is showing 
>> changes made to the blah branch on box A. (Yet on box A the changes 
>> to the blah branch are not shown in the master)
>
> You probably pulled in the 'blah' branch rather than the 'master' 
> branch because that was
> the branch that is checked out on box A. You can verify this by 
> looking at 'git log' and
> see that the commit on the blah branch is also there. To pull the 
> master branch, specify
> it explicitly, like this:
>
>     git pull boxA:path/to/repo master
>
> - Pieter
Pieter, thank you very much. Looks like that is indeed the mistake I was 
making.

```

## Sitaram Chamarty, 2009-02-12 13:08

Subject: Re: Strange branch merging.
Message-ID: <slrngp87pn.50p.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngp87pn.50p.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <49940D93.6000204@movency.com>

```
On 2009-02-12, Adam Panayis <adam@movency.com> wrote:
> I have a local machine, on this I have 2 branches. The master and one 
> named blah. My git repository is in the following location: /git/.git/
>
> I have made changes to a file on the blah branch and committed these 
> changes.
>
> I checkout the master branch and as expected the changes are no longer 
> there. I flip back to blah and I can see my changes. So far so good.
>
> I then, on a remote machine use the pull command, the remote machine 
> shows only the master branch as I have not asked it to pull blah. The 
> command I use is as follows: git pull -v ssh://user@machine one/git/.git/
>
> Once this is done I double check my branches and it shows I still only 
> have the master. Perfect. However, when I check the file I edited on my 
> local machine on the blah branch, the changes are there.

On the remote machine, your current branch was 'master'.
When you did a 'git pull', whatever you did would affect
this branch.  Meanwhile, the currently checked-out branch on
the other side was 'blah', which is what came in.

What you need to do is add the word 'master' to the 'git
pull...' command you used.  This will ensure that,
regardless of what the currently checkedout branch on the
sending side is, you will get the master branch.

```
