Re: {Spam?} push pull not working

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: {Spam?} push pull not working

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:51

Jeff King [off-list ref] writes:
For example, imagine repo1 has two branches, "master" and "foo", and the
"master" branch is checked out. When you clone it, the resulting repo2
will have remote-tracking branches for both "master" and "foo", but will
only checkout the "master" branch. Now imagine you make commits on
"foo" in repo1, and then try to push. Git's default behavior is to push
only branches which match (by name) a branch on the destination. So we
would attempt to push "master" (which is up to date), but not "foo".
Technically you are not saying anything incorrect, but the above is not an
appropriate paragraph to give to a total newbie, I would have to say.

It does not make it clear that it is insane to push to repo2 with matching
push (or "current" or "upstream" for that matter), after cloning from a
repository repo1 with a working tree to repo2 with an working tree, and
making changes at the original repo1 repository. Instead, you are giving a
false impression that pushing both "master" and "foo" explicitly would
solve the problem OP is having, which is not true.

If repo1 and repo2 with working trees want to criss-cross-exchange their
histories, both should "git pull" from the other, not "git push", and if
one side cannot initiate a connection to the other, "git push" that goes
in the other direction should be pushing into remote tracking refs of the
other in order to emulate a "git pull" that goes in the other direction.

Re: {Spam?} push pull not working

From: Jeff King <hidden>
Date: 2016-06-15 22:52:51

On Tue, Jan 24, 2012 at 12:12:54PM -0800, Junio C Hamano wrote:
quoted
For example, imagine repo1 has two branches, "master" and "foo", and the
"master" branch is checked out. When you clone it, the resulting repo2
will have remote-tracking branches for both "master" and "foo", but will
only checkout the "master" branch. Now imagine you make commits on
"foo" in repo1, and then try to push. Git's default behavior is to push
only branches which match (by name) a branch on the destination. So we
would attempt to push "master" (which is up to date), but not "foo".
Technically you are not saying anything incorrect, but the above is not an
appropriate paragraph to give to a total newbie, I would have to say.
[...]
Yeah, I agree with all of this. I was trying not to go into too much
detail because we knew so little about the situation (e.g., we don't
even know if repo2 in the example is bare or not!), but perhaps my
terseness made things even more confusing.

This might have been a better example (it exhibits the problem, but is
not an example of a terrible thing to be doing):

  1. repo1 has a "master" branch

  2. clone repo1 with "git clone --bare repo1 repo2". Repo2 now has a
     master branch.

  3. create a new "foo" branch in repo and commit on it

  4. "git push ../repo2" from repo1. This is a sane thing to be doing,
     but will not push the newly-created "foo" branch, as some users
     might expect.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help