2

Not knowing any better, I'd always used blissfully git pull (without arguments) to get remote updates.

Now that we're using branches, this has come back to haunt me.

After doing a git pull, I noticed that my local master had been merged with the other branches as well, whereas on the remote, the branches are not merged.

I'm trying to figure out how this happened so that I can avoid doing it again in the future, but no luck so far.

I didn't put anything strange in my .git/config file.

Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192

2 Answers2

1

So when I do git pull, it's supposed to merge other branches with the current branch?

No: git pull would only merge the currently checked-out branch with its remote tracking branch 'origin/branch'.
See:

See also "“Tracking Branches” And “Remote-Tracking Branches”":

git pull


Even if you can declare several remotes, you cannot pull from all of them in one step (see "pull/push from multiple remote locations").

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

See this answer:

In the simplest terms, "git pull" does a "git fetch" followed by a "git merge".

In the future, just git fetch instead of git pull.

[Original answer] What you experience is probably the correct behavior (and the behavior that you want).

Imagine this situation: Developer X has finished some important feature in her branch. She merges it back to her master.

When she pushes that, what should happen when you pull?

The current solution is that your copy of the master branch is updated so you see and get all her work (feature + merge).

This can cause problems when you develop on the master branch.

The solution is to have each developer always work in a branch. Either create a single branch per developer or create one branch per feature/bug.

That way, each developer can decide when to merge with master (your work -> master) and when to update your work branch with any changes in master.

More details:

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I should have stated in the OP that there was no merge on the remote. The branches are separate there. The merge appears to be local to just my machine, and only appeared after a `pull`. – Matt Fenwick May 16 '12 at 12:11
  • So when I do `git pull`, it's **supposed** to merge *other* branches with the current branch? Strange. I thought it would only merge tracking branches with their associated remotes branches. – Matt Fenwick May 16 '12 at 12:51