Skip to content

Commit 4607166

Browse files
author
Junio C Hamano
committed
Documentation: pull/clone ref mapping clarification.
Josef Weidendorfer points out that git-clone documentation does not mention the initial copying of remote branch heads into corresponding local branches. Also clarify the purpose of the ref mappings description in the "remotes" file and recommended workflow. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent b748421 commit 4607166

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

Documentation/git-clone.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ SYNOPSIS
1212

1313
DESCRIPTION
1414
-----------
15-
Clones a repository into a newly created directory.
15+
Clones a repository into a newly created directory. All remote
16+
branch heads are copied under `$GIT_DIR/refs/heads/`, except
17+
that the remote `master` is also copied to `origin` branch.
18+
19+
In addition, `$GIT_DIR/remotes/origin` file is set up to have
20+
this line:
21+
22+
Pull: master:origin
23+
24+
This is to help the typical workflow of working off of the
25+
remote `master` branch. Every time `git pull` without argument
26+
is run, the progress on the remote `master` branch is tracked by
27+
copying it into the local `origin` branch, and merged into the
28+
branch you are currently working on.
29+
1630

1731
OPTIONS
1832
-------
@@ -28,9 +42,10 @@ OPTIONS
2842
--shared::
2943
-s::
3044
When the repository to clone is on the local machine,
31-
instead of using hard links automatically setup
45+
instead of using hard links, automatically setup
3246
.git/objects/info/alternatives to share the objects
33-
with the source repository
47+
with the source repository. The resulting repository
48+
starts out without any object of its own.
3449

3550
--quiet::
3651
-q::
@@ -49,14 +64,13 @@ OPTIONS
4964

5065
<repository>::
5166
The (possibly remote) repository to clone from. It can
52-
be an "rsync://host/dir" URL, an "http://host/dir" URL,
53-
or [<host>:]/dir notation that is used by 'git-clone-pack'.
54-
Currently http transport is not supported.
67+
be any URL git-fetch supports.
5568

5669
<directory>::
5770
The name of a new directory to be cloned into. It is an
5871
error to specify an existing directory.
5972

73+
6074
Author
6175
------
6276
Written by Linus Torvalds <torvalds@osdl.org>

Documentation/pull-fetch-param.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ must know this is the expected usage pattern for a branch.
8282
[NOTE]
8383
You never do your own development on branches that appear
8484
on the right hand side of a <refspec> colon on `Pull:` lines;
85-
they are to be updated by `git-fetch`. The corollary is that
86-
a local branch should be introduced and named on a <refspec>
87-
right-hand-side if you intend to do development derived from
88-
that branch.
89-
This leads to the common `Pull: master:origin` mapping of a
90-
remote `master` branch to a local `origin` branch, which
91-
is then merged to a local development branch, again typically
92-
named `master`.
85+
they are to be updated by `git-fetch`. If you intend to do
86+
development derived from a remote branch `B`, have a `Pull:`
87+
line to track it (i.e. `Pull: B:remote-B`), and have a separate
88+
branch `my-B` to do your development on top of it. The latter
89+
is created by `git branch my-B remote-B` (or its equivalent `git
90+
checkout -b my-B remote-B`). Run `git fetch` to keep track of
91+
the progress of the remote side, and when you see something new
92+
on the remote branch, merge it into your development branch with
93+
`git pull . remote-B`, while you are on `my-B` branch.
94+
The common `Pull: master:origin` mapping of a remote `master`
95+
branch to a local `origin` branch, which is then merged to a
96+
ocal development branch, again typically named `master`, is made
97+
when you run `git clone` for you to follow this pattern.
9398
+
9499
[NOTE]
95100
There is a difference between listing multiple <refspec>

0 commit comments

Comments
 (0)