git - 您如何配置 git 以在每次 pull 时自动获取标签?

标签 git

这可能是也可能不是一个非常愚蠢的想法,但是您如何配置一个 git 存储库,以便自动完成的任何 pull 操作也能从其他存储库中获取标签?

根据 the docs ,看起来您可以在每个远程存储库的基础上执行此操作:

remote.<name>.tagopt
Setting this value to --no-tags disables automatic tag following when fetching from remote <name>. Setting it to --tags will fetch every tag from remote <name>, even if they are not reachable from remote branch heads. Passing these flags directly to git-fetch(1) can override this setting. See options --tags and --no-tags of git-fetch(1).

有没有办法让 --tags 成为每次提取的默认标志?

最佳答案

获取标签与获取提交 ( git fetch ) 有不同的效果,如“Does “git fetch --tags” include “git fetch”?”中所述。

后者将更新分支头,并且实际上将从那些更新的分支中获取可访问的标签。
前者将获取所有标签,但不会更新分支头。

因此,如果您的标签可以从您正在获取的分支中获取,则您不必包含 --tags默认情况下。

考虑到一些 repo 协议(protocol)(包括 linux one )的悠久历史,总是想要获取 所有 标签可能会导致标签列表困惑(标签列表被数百个不需要的标签污染).


请注意,从 git 1.9/2.0(2014 年第一季度)开始,git fetch --tags将获取所有内容(如 git fetch ),以及标签。参见“Does “ git fetch --tags ” include “ git fetch ”?”。

Request that all tags be fetched from the remote in addition to whatever else is being fetched.

所以你可以试试 remote.<name>.tagOpt config option :

git config (--global) remote.<name>.tagOpt --tags

Setting it to --tags will fetch every tag from remote <name>, even if they are not reachable from remote branch heads.

关于git - 您如何配置 git 以在每次 pull 时自动获取标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12533890/

相关文章:

git pager=cat 最后缺少换行符

git - bzr 快速导出返回 bzr : broken pipe

java - Jenkins - 如何将覆盖率报告发布到 github

git - 是否可以锁定 bitbucket 上的 pullrequest 以进行进一步提交?

git - git 上有用于重置后的钩子(Hook)吗?

svn - 每个人的源代码控制?

android - Android Studio Bumblebee 中Git 或Github pull, push 报错的解决方法 | 2021.1.1

Git commit -a 打开 GNU nano 2.2.6 我应该如何更改它以打开 Vim?

git - 你如何让 git bisect 忽略 merge 的分支?

git - 如何在多个 Linux 服务器上分发 GIT 对象?