pull-fetch-param.txt 5.9 KB
Newer Older
1
<repository>::
2 3 4 5
	The "remote" repository that is the source of a fetch
	or pull operation, or the destination of a push operation.
	One of the following notations can be used
	to name the remote repository:
J
Jonas Fonseca 已提交
6 7
+
===============================================================
8 9 10 11
- rsync://host.xz/path/to/repo.git/
- http://host.xz/path/to/repo.git/
- https://host.xz/path/to/repo.git/
- git://host.xz/path/to/repo.git/
12
- git://host.xz/~user/path/to/repo.git/
13 14 15 16 17
- ssh://host.xz/path/to/repo.git/
- ssh://host.xz/~user/path/to/repo.git/
- ssh://host.xz/~/path/to/repo.git
===============================================================
+
18 19 20 21
SSH Is the default transport protocol and also supports an
scp-like syntax.  Both syntaxes support username expansion,
as does the native git protocol. The following three are
identical to the last three above, respectively:
22 23 24 25 26 27 28
+
===============================================================
- host.xz:/path/to/repo.git/
- host.xz:~user/path/to/repo.git/
- host.xz:path/to/repo.git
===============================================================
+
29 30
To sync with a local directory, use:
+
31 32
===============================================================
- /path/to/repo.git/
J
Jonas Fonseca 已提交
33 34 35
===============================================================
+
In addition to the above, as a short-hand, the name of a
36
file in `$GIT_DIR/remotes` directory can be given; the
J
Jonas Fonseca 已提交
37 38 39
named file should be in the following format:
+
	URL: one of the above URL format
40 41
	Push: <refspec>
	Pull: <refspec>
J
Jonas Fonseca 已提交
42 43 44
+
When such a short-hand is specified in place of
<repository> without <refspec> parameters on the command
45
line, <refspec> specified on `Push:` lines or `Pull:`
46 47 48
lines are used for `git-push` and `git-fetch`/`git-pull`,
respectively.  Multiple `Push:` and and `Pull:` lines may
be specified for additional branch mappings.
J
Jonas Fonseca 已提交
49
+
50
The name of a file in `$GIT_DIR/branches` directory can be
J
Jonas Fonseca 已提交
51 52
specified as an older notation short-hand; the named
file should contain a single line, a URL in one of the
53
above formats, optionally followed by a hash `#` and the
J
Jonas Fonseca 已提交
54
name of remote head (URL fragment notation).
55
`$GIT_DIR/branches/<remote>` file that stores a <url>
J
Jonas Fonseca 已提交
56
without the fragment is equivalent to have this in the
57
corresponding file in the `$GIT_DIR/remotes/` directory.
J
Jonas Fonseca 已提交
58 59 60 61
+
	URL: <url>
	Pull: refs/heads/master:<remote>
+
62
while having `<url>#<head>` is equivalent to
J
Jonas Fonseca 已提交
63 64 65
+
	URL: <url>
	Pull: refs/heads/<head>:<remote>
66 67 68

<refspec>::
	The canonical format of a <refspec> parameter is
69 70
	`+?<src>:<dst>`; that is, an optional plus `+`, followed
	by the source ref, followed by a colon `:`, followed by
71
	the destination ref.
J
Jonas Fonseca 已提交
72
+
73
When used in `git-push`, the <src> side can be an
J
Jonas Fonseca 已提交
74
arbitrary "SHA1 expression" that can be used as an
75
argument to `git-cat-file -t`.  E.g. `master~4` (push
J
Jonas Fonseca 已提交
76 77
four parents before the current master head).
+
78
For `git-push`, the local ref that matches <src> is used
J
Jonas Fonseca 已提交
79
to fast forward the remote ref that matches <dst>.  If
80
the optional plus `+` is used, the remote ref is updated
J
Jonas Fonseca 已提交
81 82
even if it does not result in a fast forward update.
+
83
For `git-fetch` and `git-pull`, the remote ref that matches <src>
J
Jonas Fonseca 已提交
84 85
is fetched, and if <dst> is not empty string, the local
ref that matches it is fast forwarded using <src>.
86
Again, if the optional plus `+` is used, the local ref
J
Jonas Fonseca 已提交
87 88 89
is updated even if it does not result in a fast forward
update.
+
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
[NOTE]
If the remote branch from which you want to pull is
modified in non-linear ways such as being rewound and
rebased frequently, then a pull will attempt a merge with
an older version of itself, likely conflict, and fail.
It is under these conditions that you would want to use
the `+` sign to indicate non-fast-forward updates will
be needed.  There is currently no easy way to determine
or declare that a branch will be made available in a
repository with this behavior; the pulling user simply
must know this is the expected usage pattern for a branch.
+
[NOTE]
You never do your own development on branches that appear
on the right hand side of a <refspec> colon on `Pull:` lines;
105 106 107 108 109 110 111 112 113 114 115
they are to be updated by `git-fetch`.  If you intend to do
development derived from a remote branch `B`, have a `Pull:`
line to track it (i.e. `Pull: B:remote-B`), and have a separate
branch `my-B` to do your development on top of it.  The latter
is created by `git branch my-B remote-B` (or its equivalent `git
checkout -b my-B remote-B`).  Run `git fetch` to keep track of
the progress of the remote side, and when you see something new
on the remote branch, merge it into your development branch with
`git pull . remote-B`, while you are on `my-B` branch.
The common `Pull: master:origin` mapping of a remote `master`
branch to a local `origin` branch, which is then merged to a
116
local development branch, again typically named `master`, is made
117
when you run `git clone` for you to follow this pattern.
118
+
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
[NOTE]
There is a difference between listing multiple <refspec>
directly on `git-pull` command line and having multiple
`Pull:` <refspec> lines for a <repository> and running
`git-pull` command without any explicit <refspec> parameters.
<refspec> listed explicitly on the command line are always
merged into the current branch after fetching.  In other words,
if you list more than one remote refs, you would be making
an Octopus.  While `git-pull` run without any explicit <refspec>
parameter takes default <refspec>s from `Pull:` lines, it
merges only the first <refspec> found into the current branch,
after fetching all the remote refs.  This is because making an
Octopus from remote refs is rarely done, while keeping track
of multiple remote heads in one-go by fetching more than one
is often useful.
+
J
Jonas Fonseca 已提交
135 136
Some short-cut notations are also supported.
+
137 138 139
* `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`; 
  used with pull or fetch, it requests fetching everything up to
  the given tag.
J
Jonas Fonseca 已提交
140
* A parameter <ref> without a colon is equivalent to
141
  <ref>: when pulling/fetching, and <ref>`:`<ref> when
J
Jonas Fonseca 已提交
142 143
  pushing.  That is, do not store it locally if
  fetching, and update the same name if pushing.
144