Search code examples
gittagssubtree

Git subtree tags


I want to use subtree merges to pull a remote project into a directory in my own git tree. I followed the instructions here: using subtree merge

But I'm not sure how to checkout a tag. I imagine this is a common request - you want to pull in an external project but get a safe tagged version of the source. The subtree merge solution works great, but I'm not sure how to get the tag I want? Love git, but sometimes it hurts my head....


Solution

  • When you type git tag you'll get list of all tags in your repository. Remote tags also show here, and I don't know if they may conflict (didn't check that), and how to check what tags were imported to your repository.

    But what I checked is that when you add remote and it fetches from other project, you see what tags are imported. Then you can merge with that tag, for example:

    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)
    

    and it should work.

    Hope it helps a little, but I'm not as advanced with git as I would like :-)