interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / pull-fetch-param.adoc

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