9

Sometimes I see at articles command: git pull -p
But I do not found info about that in official documentation

What does that option mean?

UPD

As noted by @torek the -p option is passed to git fetch. And -p here means:

-p
--prune
Before fetching, remove any remote-tracking references that no longer exist on the remote.

But I do not understand how git-pull corporate cooperate with git-fetch?
How I can figure out how and which git options fall through one command to another?

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • 1
    The `git pull` command doesn't have its own `-p` option. What actually happens is that `-p` is passed through to `git fetch`. Not sure who downvoted this: it's correct that `-p` is not documented properly (in my opinion, `git pull` itself is not documented properly, but `git pull` should not even exist :-) ). – torek Oct 13 '16 at 19:08
  • @torek Maybe those people who thinks that `-p` stands for `--patch` and mark this question as duplicate – Eugen Konkov Oct 13 '16 at 19:59
  • @KevinB No, in that question you linked to `-p` means `--patch` – Eugen Konkov Oct 14 '16 at 06:05

3 Answers3

6

A git pull command is a shorthand command that gets interpreted as a "git fetch" plus a "git merge FETCH_HEAD" command. If you give a -p flag to a pull, it is actually the --prune command that gets run with the "git fetch" part of the command. This removes (prunes) all remote-tracking branches in your local repository that no longer exist on origin.

JGTaylor
  • 1,072
  • 8
  • 13
4

Perhaps this should be a second question now:

But I do not understand how git-pull corporate with git-fetch? How I can figure out how and which git options fall through one command to another?

(I think you mean "co-operate"1 rather than "corporate" here.)

The git pull command used to be a shell script. In the script, it's easy to tell which options are passed to git fetch, which are passed to git merge or git rebase, and which are consumed directly.

As of Git version 2.6.0, the pull command was rewritten in C. It's still possible to tell which options are which, but it's now somewhat more difficult since you must look further down to find the text spellings of each option. (This second link may decay over time as it has GitHub look up the current version of the source file, and the line numbers may change.)

I myself recommend avoiding git pull: run git fetch, then inspect the result, then choose git rebase (usually) or git merge (sometimes) as needed. I also keep an alias, git mff, that expands to git merge --ff-only, and I tend to run git fetch && git mff: if the fast-forward fails, I probably want to rebase, unless I want to merge, and this sequence (fetch and merge-if-fast-forwardable) either succeeds (in which case rebase vs merge makes no difference and we're done) or fails (in which case it's time to inspect).

(It might be worth adding an alias git fff that runs git fetch && git mff... :-) )


1This can be written as "cooperate", without the hyphen, or even as "coöperate", with a diaeresis above the second o. The diaeresis was common in English text in fine printing (and The New Yorker still uses it!), but with typewriters unable to produce it, began to be less common in the early to mid 1900s. Now that computers have Unicode and umlauts—which are technically different, but symbolically identical—I think we should restore the diaeresis to preëminence. :-)

torek
  • 448,244
  • 59
  • 642
  • 775
1

It seems answer is here

git-pull and git-fetch similarities: both are used to download new data from a remote repository.

  • git-fetch really only downloads new data from a remote repository
  • git-pull not only downloads new data; it also directly integrates new data into your current working copy files (download+merge)
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158