I have successfully created a big repo made of a few subrepos with git-subtree, let's say Master contains Slave1 and Slave2.
Master/ Slave1/ Slave2/
Now I want to tag on Master and push each tag to the slave repos, how can I do it?
If I "git push Slave2 --tags" the entire tag is transferred, but I only want the files related to Slave2 to be transferred.
You can achieve it with git-subsplit, but it's honestly a bit unpractical and slow.
As mentioned in "How to make “git push” include tags within a branch?", git 1.8.3 (May 2013) now includes a
git push --follow-tags option:
Push all the refs that would be pushed without this option, and also push annotated tags in
refs/tagsthat are missing from the remote but are pointing at commit-ish that are reachable from the refs being pushed.
Now, remember that a tag applies to the full repository (not a subdirectory), but one idea would be to:
masterinto a '
slave1_br' when you have a stable state of
Slave1, and put a tag there.
masterinto a '
slave2_br' when you have a stable state of
Slave2, and put a tag there.
git push --follow_tags slave1 slave1_br git push --follow_tags slave2 slave2_br
That is the only way I know to not push all the tags, but only the one reachable from the branch you are pushing.
I realize that involves more than one branch (
master), but it could be an alternative to
I have a solution using git subtree split
All is done on the Master Repository, you can use any branch of the Master.
git tag -a 1.0.0 -m "the tag 1.0.0"
checkout the tag
git checkout 1.0.0
Create a branch containing only slave1 for this tag
git subtree split --prefix=Slave1 -b slave1_br_1.0.0
Create the tag on this branch
git checkout slave1_br_1.0.0 git tag -a slave1_tag_1.0.0 -m "the tag 1.0.0"
Push the tag on the Slave1 repository
git push slave1 slave1_tag_1.0.0:1.0.0
Clean the branch
git checkout master git branch -D slave1_br_1.0.0 git tag -d slave1_tag_1.0.0 git gc --prune=now
Finally you will have on the Slave1 repository a tag at the same commit than the Master repository with the same name, here 1.0.0
The thing that IMHO is better is that there is no other branch appart from the temporary branch created for this (only the tag is pushed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With