checkout a specific tag with git subtree

霸气de小男生 提交于 2019-12-04 03:31:25

问题


Can I use tags in subtrees? Following a specific issue:

I have a git repository which includes an external repository as a subtree. I could add this external repository and checkout a specific branch from this repo. With git subtree pull --prefix=<dir> --squash <remote> <branch> the update from the selected branch works well.

Now is it possible to checkout a specific tag? I couldn't find some information about tags in subtrees...


回答1:


Actually any reference should work. The man page for subtree displays this.

git subtree pull  -P <prefix> <repository> <ref>

Where <ref> can be a SHA, tag or branch. Basically anything git can resolve to a commit.




回答2:


git subtree pull --prefix repository ref --squash if you used squash originally . I used a tag in place of ref without squash after first pull and got fatal: refusing to merge unrelated histories as the original pull had squash.




回答3:


I can't find a way to checkout my subtree on a specific tag or branch, using :

git subtree pull --prefix=my_subtree_dir my_remote tags/my_tag

I get the following log :

From ../remotes_dir/my_remote
* tag               my_tag     -> FETCH_HEAD
Already up-to-date.

But actually , nothing is done ! Not a single file is "checkout".

I managed to work around the problem by git removing my subtree files and read-tree them again from my remote repo :

git rm -r lib3dsp
git read-tree --prefix=lib3dsp/ -u tags/my_tag

Here is how I configured my subtree :

git remote add <my_remote>
git fetch <my_remote>
git merge -sours --no-commit <my_remote>/master
git read-tree --prefix=<my_subtree_dir> -u <my_remote>/master
git commit -m "merge <my_subtree> repo"


来源:https://stackoverflow.com/questions/34411468/checkout-a-specific-tag-with-git-subtree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!