threads / discuss / 50494

Git-pull Documentation

Subject: Git-pull Documentation

## tl;dr

2 messages between Feb 13, 2019 and Feb 13, 2019.

replies: 1people: 2as markdown or json

Maris Razvan· Feb 13, 2019, 18:13 UTC · lore
Hello,

In the "EXAMPLES" section of the git-pull documentation (https://git-scm.com/docs/git-pull#_examples) there is the following:

    "[...] Merge into the current branch the remote branch next:
    $ git pull origin next
    This leaves a copy of next temporarily in FETCH_HEAD, but does not
update any remote-
    tracking branches. [...]"

However, the second bullet-point in the "CONFIGURED REMOTE-TRACKING BRANCHES" section of the git-fetch documentation (https://git-scm.com/docs/git-fetch#_configured_remote_tracking_branches_a_id_crtb_a) states that it is possible for a command of the form "git fetch <remote> <branch>" to update a remote-tracking branch.

I checked and the current behaviour of "git pull <remote> <branch>" is to update the remote-tracking branch if required, because, as I have seen in the code, it just calls "git fetch".

I believe that the quoted example from the git-pull documentation is wrong.

Also, in the beginning of the git-pull documentation there is the following paragraph:

    "Default values for <repository> and <branch> are read from the
"remote" and "merge"
    configuration for the current branch as set by git-branch[1] --track."

I believe that this paragraph tries to state that if the <remote> and the <refspec> arguments are missing, they are replaced with branch.<name>.remote and branch.<name>.merge, respectively. However I think that this paragraph is unnecessary (and partially wrong), as the behaviour of git-pull when no arguments are given is described in the "DEFAULT BEHAVIOUR" section (https://git-scm.com/docs/git-pull#_default_behaviour) and it is a little more complicated than that, as one set of branches are used for fetching (e.g. the values of remote.<origin>.fetch) and another set of branches are used for merging (e.g. the value of branch.<name>.merge).

I hope I did not miss anything.

Thank you, Razvan Maris

Junio C Hamano· Feb 13, 2019, 22:43 UTC · re: Maris Razvan · lore

Re: Git-pull Documentation

Maris Razvan <razvan.alex.maris@gmail.com> writes:
> I checked and the current behaviour of "git pull <remote> <branch>" is
> to update the remote-tracking branch if required, because, as I have
> seen in the code, it just calls "git fetch".

The thing is, "git fetch origin next" did *NOT* update remote-tracking branch refs/remotes/origin/next for a long time, until f2690487 ("fetch: opportunistically update tracking refs", 2013-05-11) happend.

The series did not update the documentation all that much, which was why you are seeing neither "git fetch" nor "git pull" documented to perform this "opportunistic update of tracking refs". The only change the topic with f2690487 brought in to the Documentation was the attached bit.

Documentation updates to both pull and fetch are very much welcomed.
Thanks.
$ git diff --stat -p 67b57a90f4 db400949b31a Documentation/
 Documentation/pull-fetch-param.txt | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt
index 94a9d32f1d..18cffc25b8 100644
--- a/Documentation/pull-fetch-param.txt
+++ b/Documentation/pull-fetch-param.txt
@@ -68,6 +68,11 @@ Some short-cut notations are also supported.
 +
 * `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`;
   it requests fetching everything up to the given tag.
-* A parameter <ref> without a colon is equivalent to
-  <ref>: when pulling/fetching, so it merges <ref> into the current
-  branch without storing the remote branch anywhere locally
+ifndef::git-pull[]
+* A parameter <ref> without a colon fetches that ref into FETCH_HEAD,
+endif::git-pull[]
+ifdef::git-pull[]
+* A parameter <ref> without a colon merges <ref> into the current
+  branch,
+endif::git-pull[]
+  and updates the remote-tracking branches (if any).

← back to recent threads