Information Technology Reference
In-Depth Information
fig --unset
commands turned her local tracking branch named
master
into an
ordinary local branch. That's good.
Now Sarah wants to create her local tracking branch named
john
to be connected
with John's
master
branch. She runs:
# sarah's command
$ git branch john
$ git branch --set-upstream-to=origin/master john
Then she fetches from John's repository with
$ git fetch
. The command
fetches all the missing revisions from the
master
branch in John's repo as well as a
new remote tracking branch
remotes/origin/sarah
. Sarah doesn't need John's
origin/sarah
branch, but there is no way to avoid it.
Next Sarah switches to the
john
branch and checks its status:
# sarah's command
$ git checkout john
$ git status -sb
The output says that the current branch (
john
) is three commits behind the remote
tracking branch (which is
origin/master
). She updates her
john
branch with:
$ git rebase
She inspects John's revisions
j4
,
j5
,
j6
. Then she merges John's work into her
master
branch:
$ git rebase john master
How does John update his project?
To download and merge all of Sarah's code John runs following commands:
$ git fetch
$ git checkout sarah
$ git rebase
$ git rebase sarah master