]>
Commit | Line | Data |
---|---|---|
0c04094b | 1 | <repository>:: |
bccf5956 | 2 | The "remote" repository that is the source of a fetch |
58124733 JF |
3 | or pull operation. This parameter can be either a URL |
4 | (see the section <<URLS,GIT URLS>> below) or the name | |
5 | of a remote (see the section <<REMOTES,REMOTES>> below). | |
ab9b3138 | 6 | |
9c4a036b BG |
7 | ifndef::git-pull[] |
8 | <group>:: | |
9 | A name referring to a list of repositories as the value | |
10 | of remotes.<group> in the configuration file. | |
11 | (See linkgit:git-config[1]). | |
12 | endif::git-pull[] | |
13 | ||
ab9b3138 | 14 | <refspec>:: |
db4e4113 MB |
15 | Specifies which refs to fetch and which local refs to update. |
16 | When no <refspec>s appear on the command line, the refs to fetch | |
17 | are read from `remote.<repository>.fetch` variables instead | |
18 | ifndef::git-pull[] | |
19 | (see <<CRTB,CONFIGURED REMOTE-TRACKING BRANCHES>> below). | |
20 | endif::git-pull[] | |
21 | ifdef::git-pull[] | |
f6a65de6 PB |
22 | (see the section "CONFIGURED REMOTE-TRACKING BRANCHES" |
23 | in linkgit:git-fetch[1]). | |
db4e4113 MB |
24 | endif::git-pull[] |
25 | + | |
26 | The format of a <refspec> parameter is an optional plus | |
83558a41 | 27 | `+`, followed by the source <src>, followed |
db4e4113 | 28 | by a colon `:`, followed by the destination ref <dst>. |
83558a41 JH |
29 | The colon can be omitted when <dst> is empty. <src> is |
30 | typically a ref, but it can also be a fully spelled hex object | |
31 | name. | |
df8baa42 | 32 | + |
c0192df6 JK |
33 | A <refspec> may contain a `*` in its <src> to indicate a simple pattern |
34 | match. Such a refspec functions like a glob that matches any ref with the | |
35 | same prefix. A pattern <refspec> must have a `*` in both the <src> and | |
36 | <dst>. It will map refs to the destination by replacing the `*` with the | |
37 | contents matched from the source. | |
38 | + | |
39 | If a refspec is prefixed by `^`, it will be interpreted as a negative | |
40 | refspec. Rather than specifying which refs to fetch or which local refs to | |
41 | update, such a refspec will instead specify refs to exclude. A ref will be | |
42 | considered to match if it matches at least one positive refspec, and does | |
43 | not match any negative refspec. Negative refspecs can be useful to restrict | |
44 | the scope of a pattern refspec so that it will not include specific refs. | |
45 | Negative refspecs can themselves be pattern refspecs. However, they may only | |
46 | contain a <src> and do not specify a <dst>. Fully spelled out hex object | |
47 | names are also not supported. | |
48 | + | |
5cc32687 JH |
49 | `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`; |
50 | it requests fetching everything up to the given tag. | |
51 | + | |
3598a308 | 52 | The remote ref that matches <src> |
ae6a4703 ÆAB |
53 | is fetched, and if <dst> is not an empty string, an attempt |
54 | is made to update the local ref that matches it. | |
55 | + | |
56 | Whether that update is allowed without `--force` depends on the ref | |
57 | namespace it's being fetched to, the type of object being fetched, and | |
58 | whether the update is considered to be a fast-forward. Generally, the | |
59 | same rules apply for fetching as when pushing, see the `<refspec>...` | |
60 | section of linkgit:git-push[1] for what those are. Exceptions to those | |
61 | rules particular to 'git fetch' are noted below. | |
62 | + | |
0bc8d71b ÆAB |
63 | Until Git version 2.20, and unlike when pushing with |
64 | linkgit:git-push[1], any updates to `refs/tags/*` would be accepted | |
73e94796 | 65 | without `+` in the refspec (or `--force`). When fetching, we promiscuously |
0bc8d71b | 66 | considered all tag updates from a remote to be forced fetches. Since |
73e94796 | 67 | Git version 2.20, fetching to update `refs/tags/*` works the same way |
0bc8d71b ÆAB |
68 | as when pushing. I.e. any updates will be rejected without `+` in the |
69 | refspec (or `--force`). | |
ae6a4703 ÆAB |
70 | + |
71 | Unlike when pushing with linkgit:git-push[1], any updates outside of | |
72 | `refs/{tags,heads}/*` will be accepted without `+` in the refspec (or | |
73 | `--force`), whether that's swapping e.g. a tree object for a blob, or | |
74 | a commit for another commit that's doesn't have the previous commit as | |
75 | an ancestor etc. | |
76 | + | |
0bc8d71b ÆAB |
77 | Unlike when pushing with linkgit:git-push[1], there is no |
78 | configuration which'll amend these rules, and nothing like a | |
79 | `pre-fetch` hook analogous to the `pre-receive` hook. | |
80 | + | |
ae6a4703 ÆAB |
81 | As with pushing with linkgit:git-push[1], all of the rules described |
82 | above about what's not allowed as an update can be overridden by | |
83 | adding an the optional leading `+` to a refspec (or using `--force` | |
84 | command line option). The only exception to this is that no amount of | |
85 | forcing will make the `refs/heads/*` namespace accept a non-commit | |
86 | object. | |
df8baa42 | 87 | + |
bccf5956 | 88 | [NOTE] |
f471dbc5 JH |
89 | When the remote branch you want to fetch is known to |
90 | be rewound and rebased regularly, it is expected that | |
91 | its new tip will not be descendant of its previous tip | |
92 | (as stored in your remote-tracking branch the last time | |
93 | you fetched). You would want | |
94 | to use the `+` sign to indicate non-fast-forward updates | |
95 | will be needed for such branches. There is no way to | |
96 | determine or declare that a branch will be made available | |
97 | in a repository with this behavior; the pulling user simply | |
bccf5956 | 98 | must know this is the expected usage pattern for a branch. |
5d59a32f | 99 | ifdef::git-pull[] |
bccf5956 JL |
100 | + |
101 | [NOTE] | |
fdd08979 | 102 | There is a difference between listing multiple <refspec> |
0b444cdb | 103 | directly on 'git pull' command line and having multiple |
5d59a32f JH |
104 | `remote.<repository>.fetch` entries in your configuration |
105 | for a <repository> and running a | |
0b444cdb | 106 | 'git pull' command without any explicit <refspec> parameters. |
5d59a32f | 107 | <refspec>s listed explicitly on the command line are always |
fdd08979 | 108 | merged into the current branch after fetching. In other words, |
5d59a32f JH |
109 | if you list more than one remote ref, 'git pull' will create |
110 | an Octopus merge. On the other hand, if you do not list any | |
111 | explicit <refspec> parameter on the command line, 'git pull' | |
112 | will fetch all the <refspec>s it finds in the | |
113 | `remote.<repository>.fetch` configuration and merge | |
114 | only the first <refspec> found into the current branch. | |
115 | This is because making an | |
fdd08979 JH |
116 | Octopus from remote refs is rarely done, while keeping track |
117 | of multiple remote heads in one-go by fetching more than one | |
118 | is often useful. | |
5d59a32f | 119 | endif::git-pull[] |