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 check the tag. I assume this is a general request - you want to use an external project, but you will get a secure labeled version of the source. The subtree merge solution works fine, but I'm not sure how to get the tag I want? Love git, but sometimes it hurts my head ....

+6
git tags
source share
3 answers

When you type git tag you will get a list of all the tags in your repository. Remote tags are also displayed here, and I don’t know if they can conflict (did not check), and how to check which tags were imported into your repository.

But what I checked is that when you add remote access and retrieve it from another project, you see which tags are being imported. Then you can merge with this 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 this helps a bit, but I'm not as advanced with git as I would like :-)

+3
source share

GitHub has a kernel.org HowTo application: http://help.github.com/subtree-merge/

+2
source share

I did this for a sample Github project called hesco / hesco-weave as follows:

I used curl, jq , cut and tail commands in the following examples, so you need to have them before running the examples.

First , the last two project tags were found:

 me@ubuntu : ~ $ curl -s https://api.github.com/repos/hesco/hesco-weave/git/refs/tags | jq -r ".[].ref" | cut -d "/" -f 3 v0.1 v0.2 v0.3 v0.4 v0.5 v0.6 v0.7 v0.8 v0.8.6 v0.8.7 me@ubuntu : ~ $ curl -s https://api.github.com/repos/hesco/hesco-weave/git/refs/tags | jq -r ".[].ref" | cut -d "/" -f 3 | tail -n 3 v0.8.6 v0.8.7 

Or, if you have a verified version of the project:

 me@ubuntu : ~/github/hesco-weave (master) $ git remote -v origin https://github.com/hesco/hesco-weave.git (fetch) origin https://github.com/hesco/hesco-weave.git (push) me@ubuntu : ~/github/hesco-weave (master) $ git tag -l v0.1 v0.2 v0.3 v0.4 v0.5 v0.6 v0.7 v0.8 v0.8.6 v0.8.7 me@ubuntu : ~/github/hesco-weave (master) $ git tag -l | tail -n 2 v0.8.6 v0.8.7 

sha of refs is as follows:

 me@linux : ~ $ git ls-remote | tail -n 2 be74d8368acd4815b6863daded46a232944e0d84 refs/tags/v0.8.6 9181306caa304b4cf8b3764b1446c0c4006833d8 refs/tags/v0.8.7 

Second , a git repository is created:

 me@linux : ~ $ mkdir -p ~/test me@linux : ~ $ cd ~/test me@linux : ~/test $ git init Initialized empty Git repository in ~/test/.git/ me@linux : ~/test $ touch README.md me@linux : ~/test $ git add . me@linux : ~/test $ git commit -m "README.md added" [master (root-commit) b1ac90e] README.md added 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md me@linux : ~/test (master) $ git log commit 19c0570a414c4fd1635444b7a937dfc41c93a847 Author: Me < me@linux.me > Date: Wed Jun 14 13:02:05 2017 +0200 README.md added 

Third , the Github repository tag v0.8.6 is added to the created repository as a subtree:

 me@linux : ~/test (master) $ git subtree add --squash --prefix=weave https://github.com/hesco/hesco-weave.git v0.8.6 git fetch https://github.com/hesco/hesco-weave.git v0.8.6 warning: no common commits remote: Counting objects: 543, done. remote: Compressing objects: 100% (193/193), done. remote: Total 543 (delta 306), reused 536 (delta 306), pack-reused 0 Receiving objects: 100% (543/543), 93.19 KiB | 0 bytes/s, done. Resolving deltas: 100% (306/306), done. From https://github.com/hesco/hesco-weave * tag v0.8.6 -> FETCH_HEAD Added dir 'weave' 

Trace Information:

 me@linux : ~/test (master) $ git log commit e5dc318c4437cd22ebddb9e82e8c419aef72a781 Merge: b1ac90e 19c0570 Author: me < me@linux.me > Date: Wed Jun 14 13:02:25 2017 +0200 Merge commit '19c0570a414c4fd1635444b7a937dfc41c93a847' as 'weave' commit 19c0570a414c4fd1635444b7a937dfc41c93a847 Author: me < me@linux.me > Date: Wed Jun 14 13:02:25 2017 +0200 Squashed 'weave/' content from commit be74d83 git-subtree-dir: weave git-subtree-split: be74d8368acd4815b6863daded46a232944e0d84 commit b1ac90efbfe5978bac52984c29e6ec7904ed9a75 Author: me < me@linux.me > Date: Wed Jun 14 13:02:05 2017 +0200 README.md added 

Finally , the weave subtree with the new v0.8.7 tag merges with git subtree pull :

 me@linux : ~/test (master) $ git subtree pull --squash --prefix=weave https://github.com/hesco/hesco-weave.git v0.8.7 warning: no common commits remote: Counting objects: 548, done. remote: Compressing objects: 100% (195/195), done. remote: Total 548 (delta 311), reused 541 (delta 309), pack-reused 0 Receiving objects: 100% (548/548), 90.50 KiB | 0 bytes/s, done. Resolving deltas: 100% (311/311), done. From https://github.com/hesco/hesco-weave * tag v0.8.7 -> FETCH_HEAD Merge made by the 'recursive' strategy. weave/Changelog | 1 + weave/Modulefile | 2 +- weave/README.md | 2 +- weave/metadata.json | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 

Trace Information:

 me@linux : ~/test (master) $ git log commit 9116e133c8d84de1df9883a8b5558a2350ebc86e Merge: e5dc318 eb2e273 Author: me < me@linux.me > Date: Wed Jun 14 13:03:16 2017 +0200 Merge commit 'eb2e2733a75d59eb1adebf4755d5b11cb74e2b98' commit eb2e2733a75d59eb1adebf4755d5b11cb74e2b98 Author: me < me@linux.me > Date: Wed Jun 14 13:03:16 2017 +0200 Squashed 'weave/' changes from be74d83..9181306 9181306 make release used to update version to v0.8.7 3871cf5 Update changelog, tag v0.8.6, fix link in README REVERT: be74d83 Update changelog, tag v0.8.6, fix link in README git-subtree-dir: weave git-subtree-split: 9181306caa304b4cf8b3764b1446c0c4006833d8 commit e5dc318c4437cd22ebddb9e82e8c419aef72a781 Merge: b1ac90e 19c0570 Author: me < me@linux.me > Date: Wed Jun 14 13:02:25 2017 +0200 Merge commit '19c0570a414c4fd1635444b7a937dfc41c93a847' as 'weave' commit 19c0570a414c4fd1635444b7a937dfc41c93a847 Author: me < me@linux.me > Date: Wed Jun 14 13:02:25 2017 +0200 Squashed 'weave/' content from commit be74d83 git-subtree-dir: weave git-subtree-split: be74d8368acd4815b6863daded46a232944e0d84 commit b1ac90efbfe5978bac52984c29e6ec7904ed9a75 Author: me < me@linux.me > Date: Wed Jun 14 13:02:05 2017 +0200 README.md added me@linux : ~/test (master) $ ll total 4 -rw-rw-r-- 1 me me 0 Jun 14 13:01 README.md drwxrwxr-x 8 me me 4096 Jun 14 13:03 weave 
0
source share

All Articles