Reputation: 2433
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.
Updating my question based on the responses below:
So here is what I tried:
Created a new repo which has no tags
$git ls-remote origin refs/tags/* $
Created a tag:
git tag 20221208_144648_TEST -m messages
Set the namespace:
export GIT_NAMESPACE=foo
Pushed the ref
git -c core.quotepath=false push -v origin refs/tags/20221208_144648_TEST
List the refs
$git ls-remote origin refs/tags/*
362cb81e90fca03c73e0d3e5ea44883c6298a598 refs/tags/20221208_144648_TEST
538a4686d9dd17c1a7d770e718d21b95507393c1 refs/tags/20221208_144648_TEST^{}
Unset the namespace
unset GIT_NAMESPACE
List remote refs
git ls-remote origin refs/tags/*
362cb81e90fca03c73e0d3e5ea44883c6298a598 refs/tags/20221208_144648_TEST
538a4686d9dd17c1a7d770e718d21b95507393c1 refs/tags/20221208_144648_TEST^{}
note: I don't see the namespace yet.
Upvotes: 1
Views: 287
Reputation: 30888
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.
Upvotes: 0
Reputation: 1030
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^{}
Upvotes: 2