On Sat, 2016-08-27 at 10:07 -0700, Michael wrote:
> if someone forked my repository, did work on "master", and submitted
> it to go onto my "master", then how do I say "No, come in on a branch
> named devB instead"?

Something important to understand is that your local repository and
every remote you register all have their own "namespaces" for branches.
Because of this, in fact someone else's "master" can never interfere
with your "master" or a different remote's "master".

The default name for the remote you cloned from is "origin".  That means
there's an "origin/master", "origin/foo", "origin/bar", etc. for every
branch ("master", "foo", "bar") that exists on the remote.  So you can
see what the remote's master contained with "git log origin/master" (as
of the last time you fetched from that remote).  You can compare them
with "git diff origin/foo foo", etc.

You also have your own branches, "master", "foo", "baz", etc. which are
local to your repository and don't exist in the remote.

And if you add a second remote (which of course has to have its own
name, not "origin") then you will get all of its branches imported into
your repository, but under that remote's name, so "other/master",
"other/foo", "other/boz".

So there's really no reason to be concerned about other people using
"master", since that's their "master" and is not your "master".  They
are in different namespaces and Git won't get them confused.

However, people soon discovered that _much_ of the time, you really only
have a single remote and the extra command line fu needed to keep
everything straight was annoyingly redundant.  So Git has a concept of a
"tracking branch", which is a local branch which is tracking a branch in
one of your remotes.  If your local branch is a tracking branch for some
remote's branch, then when you pull from that remote Git knows to merge
from that remote's branch into your branch.

Note there's no reason at all that the remote branch and the local
tracking branch have to have the same root name.  A local branch "foo"
could be tracking a remote "other/fubar".  So, you could have a local
branch "master" which tracks "origin/master" and a different local
branch "master_other" which tracks "other/master".

You might try reading
https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches which I
think explains this fairly well.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to