如何使用另一个存储库中的git子树拉出我的所有标签?

时间:2016-10-03 19:07:41

标签: git github git-subtree git-tag

如何使用来自其他存储库的git子树拉取我的所有标签?

我刚创建了一个新的存储库,并使用此命令添加了另一个git子树:

git subtree add --prefix=Galileo https://github.com/evandrocoan/Galileo master

但它没有存储库evandrocoan/Galileo上的任何标记。您可以在https://github.com/evandrocoan/AlliedModdersFiles上看到它。如何获得它们?

还有另一个答案checkout a specific tag with git subtree,我收到了这个错误:

git subtree pull --prefix=Galileo https://github.com/evandrocoan/Galileo tags/3.2.3
Working tree has modifications.  Cannot add.

我的工作树干净/有修改。此外,我需要处理标记名称冲突,因为几个子树将从存储库main_repo / SubtreeA,main_repo / SubtreeB,main_repo / SubtreeC等获取与1.0.0,1.0.1同名的标记。

还有其他问题Git subtree tags,但我不明白这意味着什么:

git merge -s ours --no-commit v0.1.2 # instead of: Bproject/master (2)
git read-tree --prefix=dir-B/ -u v0.1.2 # instead of: Bproject/master (3)

我怎么能用它来获取我的标签。不知怎的,这与:

有关
  1. git subtree fetch - unwanted remote tags
  2. How to push tags with git subtree?

1 个答案:

答案 0 :(得分:1)

要获取标签,请执行以下操作:

git remote add galileo_remote https://github.com/evandrocoan/Galileo
git fetch --tags

但它会变得一团糟,因为所有子树的所有标签都会相互冲突。对此的一个解决方案是为它们添加前缀,但这样做很麻烦。那么最好的方法是不处理主存储库上的子树标记,而是处理专用的子树存储库。

现在每个人都可能拥有真棒标签1.0.0,而不需要彼此冲突。这是一种更好的方法,因为它可以保持主存储库标记的清洁,而不会使所有标记从几个带前缀的子树存储库中弄乱。