GIT 从特定标签拉/取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3964368/
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
GIT pull/fetch from specific tag
提问by Senthil A Kumar
Is there a way to pull/fetch code from a specific tag in a repo.
有没有办法从存储库中的特定标签中提取/获取代码。
Am aware that after clone, i can checkout to the tag but is it possible to specify a tag during a pull?
我知道克隆后,我可以结帐到标签,但是否可以在拉取过程中指定标签?
In ClearCase i can rebase or deliver a specific baseline of code, is there a way where i can use git tags similarly to pull/push code upto a specified tag?
在 ClearCase 中,我可以重新设定或交付特定的代码基线,有没有一种方法可以使用 git 标签类似于将代码拉/推到指定标签?
采纳答案by VonC
It will be a bit different with ClearCase, because you can only rebase a baseline produced on the parent Stream (although you can deliver any baseline from any Stream to your Stream).
So there are some limitations to the kind of merge you do with ClearCase.
ClearCase 会有点不同,因为您只能对在父 Stream 上生成的基线进行变基(尽管您可以将任何基线从任何 Stream 传送到您的 Stream)。
因此,您使用 ClearCase 进行的合并类型存在一些限制。
With Git, you can merge any commit to the HEAD
of your current branch.
If that commit comes from a remote repo, it will be first imported in the remote branches of your local repo ('fetch
' part of the git pull
) and then merged.
使用 Git,您可以将任何提交合并到HEAD
当前分支的 。
如果该提交来自远程存储库,它将首先导入本地存储库的远程分支( 的“ fetch
”部分git pull
),然后合并。
git pull [options] [<repository> [<refspec>…]]
The "refspec
" part of the git pull command means you can pull anything.
refspec
git pull 命令的“ ”部分意味着你可以拉任何东西。
<refspec>
can name an arbitrary remote ref (for example, the name of a tag) or even a collection of refs with corresponding remote tracking branches (e.g.,refs/heads/:refs/remotes/origin/
), but usually it is the name of a branch in the remote repository.
<refspec>
可以命名任意远程引用(例如,标签的名称),甚至是具有相应远程跟踪分支(例如,refs/heads/:refs/remotes/origin/
)的引用集合,但通常它是远程存储库中分支的名称。
See also How to pull remote branch with specified commit id?
回答by ryenus
Pull is fetch + merge.
拉取+合并。
Talking about how to fetch a specific remote ref (either a tag or branch), probably an example is better at clarifying this:
谈论如何获取特定的远程引用(标签或分支),可能有一个例子更能说明这一点:
git fetch origin :refs/remotes/origin/master
Or a shorter form:
或者更短的形式:
git fetch origin :remotes/origin/master
Note this works even if remotes/origin/master
has been removed locally.
请注意,即使remotes/origin/master
已在本地删除,这也有效。
Another example for creating a local branch directly from a remote tag
直接从远程标签创建本地分支的另一个示例
git fetch <repo_url> +refs/tags/<TAG>:<branch>