I want to create tags in different namespaces.
Read up on: https://git-scm.com/docs/gitnamespaces but I am not sure, I understand it correctly.
So, lets say
I create a tag and push it upstream using:
git -c core.quotepath=false push -v origin refs/tags/20221208_144648
Now see the tags using:
git ls-remote --tags <repo_url.git> refs/tags/*
This works great.
Now, lets say I want to create a tag in a namespace:
export GIT_NAMESPACE=foo
git -c core.quotepath=false push -v origin refs/tags/20221208_144648_TEST
or
git -c core.quotepath=false push -v origin refs/namespace/foo/tags/20221208_144648_TEST
I only see the tag that I first created when I run:
git ls-remote --tags <repo_url.git> refs/tags/*
Even tried:
git ls-remote --tags <repo_url.git> refs/namespace/foo/tags/*
I am clearly missing something here. Any explanation will be appreciated.
CodePudding user response:
You missed an s in refs/namespaces (not refs/namespace), and the reference path should be refs/namespaces/foo/refs/tags/xxx not refs/namesapces/foo/tags/xxx (the refs/ before tags/ was missed), but neither are the point.
You can use either way (GIT_NAMESPACE or refs/namespaces/) to specify a namespace, but not both!
If you exported GIT_NAMESPACE=foo and then pushed an object to refs/namespaces/foo/refs/tags/, then it would actually be pushed to refs/namespaces/foo/refs/namespaces/foo/refs/tags, equivalent to namespace foo/foo.
Actually, I tried with your steps and get expected results.
Steps:
git tag 20221208_144648_TEST -m messages
export GIT_NAMESPACE=foo
git -c core.quotepath=false push -v origin refs/tags/20221208_144648_TEST
Results:
$ git ls-remote origin refs/tags/*
a750776e2ce551b597a87804424e95b90f26b391 refs/tags/20221208_144648_TEST
852d0196ca768d181bb027d0f37a0913b00bc7cf refs/tags/20221208_144648_TEST^{}
After unset GIT_NAMESPACE:
$ git ls-remote origin refs/tags/*
a750776e2ce551b597a87804424e95b90f26b391 refs/namespaces/foo/refs/tags/20221208_144648_TEST
852d0196ca768d181bb027d0f37a0913b00bc7cf refs/namespaces/foo/refs/tags/20221208_144648_TEST^{}
CodePudding user response:
You used --tags, so it only searches refs/tags/* for the refs that match the pattern. However, the pattern is refs/namespace/foo/tags/*. None of the tags would match the pattern. Use git ls-remote <repo_url.git> refs/namespace/foo/tags/* instead.
