Information Technology Reference
In-Depth Information
How does a developer contribute to the project?
Every developer contributes by committing in his or her
master
branch:
$ git checkout master
$ git simple-commit x y z
How does Sarah download John's contributions?
She follows the procedure
How does John update his project?
using the
john
branch
name instead of
sarah
:
$ git fetch
$ git checkout john
$ git rebase
$ git rebase john master
How It Works
This recipe emphasizes the distributed nature of git. As you can see, every repository
can be used as a source of revisions. You can fetch from every repository you have ac-
cess to. Git doesn't restrict fetch to some special central repositories, as in
shared-
repo
in Recipe 10-2, stored on a server. The push operation is restricted by default to
bare repositories, but we can also circumvent this restriction. It will be done in Recipe
10-10.
If you follow the recipe carefully, you will notice that the
$ git fetch
operation
creates remote tracking branches for all the branches in the remote repository. When
you finish the recipe, John's repository contains following branches (as returned by
$
git branch -a -vv
):
* master 542d21a z
sarah bacddd0 [origin/master] j6
remotes/origin/john bacddd0 j6
remotes/origin/master bacddd0 j6