Fetching all tags from a remote with git pull
I currently have a git remote setup like the following:
[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.
I'd like git pull
to additionally fetch all tags 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).
Is there a way to make git pull
fetch all remote tags by default, in addition to the remote heads?
You should be able to accomplish this by adding a refspec for tags to your local config. Concretely:
[remote "upstream"]
url = <redacted>
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/tags/*:refs/tags/*
一个简单的git fetch --tags
为我工作。
The --force
option is useful for refreshing the local tags. Mainly if you have floating tags:
git fetch --tags --force
The git pull option has also the --force
options, and the description is the same:
When git fetch is used with : refspec, it refuses to update the local branch unless the remote branch it fetches is a descendant of . This option overrides that check.
but, according to the doc of --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
链接地址: http://www.djcxy.com/p/16020.html
上一篇: 发布到BitBucket时的“Funny RefName”
下一篇: 使用git pull从远程获取所有标签