我们可以设置一个 Git 默认值来在远程拉取期间获取所有标签吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16678072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can we set a Git default to fetch all tags during a remote pull?
提问by jleahy
I currently have a git remote setup like the following:
我目前有一个 git 远程设置,如下所示:
[remote "upstream"]
url = <redacted>
fetch = +refs/heads/*:refs/remotes/upstream/*
When I issue git pull
on branch master, all remote heads are fetched into remotes/upstream, then remotes/upstream/master is merged into master. Any tags that can be reached are also fetched at the same time, which is very convenient.
当我git pull
在分支 master 上发布时,所有远程头都被提取到 remotes/upstream,然后 remotes/upstream/master 合并到 master。任何可以到达的标签也同时被抓取,非常方便。
I'd like git pull
to additionally fetch alltags from the remote, not just those that are directly reachable from the heads. I originally tried seting tagopt == --tags
, but found this caused only tags to be fetch and thus broke everything. (Junio even says that's a horrendous misconfiguation).
我还想从遥控器中git pull
获取所有标签,而不仅仅是那些可以直接从头部访问的标签。我最初尝试设置tagopt == --tags
,但发现这只会导致获取标签,从而破坏了一切。(Junio 甚至说这是一个可怕的错误配置)。
Is there a way to make git pull
fetch all remote tags by default, in addition to the remote heads?
git pull
除了远程头之外,有没有办法默认获取所有远程标签?
采纳答案by joshtkling
You should be able to accomplish this by adding a refspec for tags to your local config. Concretely:
您应该能够通过将标签的 refspec 添加到本地配置来完成此操作。具体来说:
[remote "upstream"]
url = <redacted>
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/tags/*:refs/tags/*
回答by russoue
A simple git fetch --tags
worked for me.
一个简单的git fetch --tags
对我有用。
回答by yucer
The --force
option is useful for refreshing the local tags. Mainly if you have floating tags:
该--force
选项对于刷新本地标签很有用。主要是如果您有浮动标签:
git fetch --tags --force
The git pull option has also the --force
options, and the description is the same:
git pull 选项也有--force
选项,描述是一样的:
When git fetch is used with <rbranch>:<lbranch> refspec, it refuses to update the local branch <lbranch> unless the remote branch <rbranch> it fetches is a descendant of <lbranch>. This option overrides that check.
当 git fetch 与 <rbranch>:<lbranch> refspec 一起使用时,它拒绝更新本地分支 <lbranch>,除非它获取的远程分支 <rbranch> 是 <lbranch> 的后代。此选项会覆盖该检查。
but, according to the doc of --no-tags
:
但是,根据以下文档--no-tags
:
By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally.
默认情况下,指向从远程存储库下载的对象的标签被提取并存储在本地。
If that default statement is not a restriction, then you can also try
如果该默认语句不是限制,那么您也可以尝试
git pull --force
回答by Vasantha Ganesh K
For me the following seemed to work.
对我来说,以下似乎有效。
git pull --tags
回答by amulamul
It's simple. Do a
这很简单。做一个
git fetch --all
git fetch --all
回答by event
I use this with magit on kernel.org
我在 kernel.org 上将它与 magit 一起使用
[remote "upstream"]
url = <redacted>
fetch = +refs/heads/*:refs/remotes/upstream/*
tagOpt = --tags