tags:

views:

84

answers:

1
+2  Q: 

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....

+1  A: 

When you type git tag you'll get list of all tags in your repository. Remote tags also show here, and I don't knot if they may conflict (didn't checked 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 :-)

MBO
If I don't provide Bproject/master, how does git know which remote I'm merging with?
cmaughan
@cmaughan Git doesn't know. All it knows are sha's and each sha (represented also by tag, or Bproject/master) refer to some commit, which has parents, and so on. That's why you fetch (`-f` option in `git remote`) changes from remote repository - you get all commits and its sha's. And then you merge some tree (remote, by sha of course) to your tree. Hope thats how it works
MBO
Okay - sounds good to me! The collision tags thing is something I've been wondering about - if I have a tag - v1.5 on my app, and the remote as a v1.5 tag, how does git sort this out? Either way, seems to be the solution I was looking for...
cmaughan
@cmaughan I checked and if you already have given tag in your project, then tag from remote project is not added to repository. Also if you have tag from remote project, then you cannot add same tag to your repo. You can of course force to make new tag (`-f` option), but then you override tag. I think tags aren't mean to work between different projects.
MBO