How to supply --prune-tags to git pull?

Viewed 87

From https://git-scm.com/docs/git-pull/2.34.0:

-p --prune Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying --prune-tags is a shorthand for providing the tag refspec.

However, my git pull gives me an error:

$ git --version
git version 2.34.1.windows.1

$ git pull --prune-tags
error: unknown option `prune-tags'

$ git pull --prune --prune-tags
error: unknown option `prune-tags'

$ git pull --prune --tags --prune-tags
error: unknown option `prune-tags'

Even:

$ git pull --prune --tags origin --prune-tags
error: unknown option `prune-tags'

However, this works, assuming t1 is a name of the tag:

$ git pull --prune --tags origin t1
From ssh://[stripped]
 * tag               t1         -> FETCH_HEAD
Already up to date.
1 Answers

Indeed, it looks like a bug in how options are handled by git pull.

Testing with git version 2.35.0 :

  • git pull --prune --prune-tags origin yields "unknown option 'prune-tags'"
  • but git fetch --prune --prune-tags origin works (and deletes said tags)

[update]

as @torek commented, note that the option is not listed in git pull options : --prune-tags is hinted at in the --prune section of git help pull, which is the same paragraph as the one from git help fetch. It would however make sense for git pull to handle that option as well.

Related