Skip to contentSkip to conversation

git pull on a branch semantics

DISCUSSION Luben Tuikov 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

pwd is a git repo; current branch is A; there's a few branches in this git repo.
In .git/remotes/ I've a file name "projectC", which looks like:

URL:<url>
Pull:projectC:projectC
Push:projectC:projectC

That is both here and remotely I've projectC being a branch here and remotely.

I'd like to pull changes to projectC only, from the remote projectC to the local projectC, but my current branch is A.

I blissfully do:

git pull projectC

git correctly tells me that the heads are the same in branchC here and remote, but it then goes ahead to merge projectC in the current branch A (project A) since they have a common ancestor.

But because of the "Pull" line in .git/remotes/projectC what the intention was is to pull from projectC remotely and merge any new changes in projectC locally, and only in projectC (irrespective of what the current branch is (in the pwd)).

Is this behavior a bug or is this a "feature"?

Thanks,
Luben

#1 lore raw
Quoted 7 lines · Luben Tuikov

URL:<url>
Pull:projectC:projectC
Push:projectC:projectC

That is both here and remotely I've projectC being a branch here and remotely.

Quoted 6 lines

I'd like to pull changes to projectC only, from the remote projectC to the local projectC, but my current branch is A.

I blissfully do:

git pull projectC

You wanted to "git fetch", not "git pull" which is "fetch followed by merge into the current branch".

#2 lore raw
Quoted 2 lines · --- Junio C Hamano

You wanted to "git fetch", not "git pull" which is "fetch followed by merge into the current branch".

Ah, ok, thanks Junio.

Luben