smarber
smarber

Reputation: 5084

git with many remotes: get the hash that corresponds to a tag of a remote other than origin

I have a project project1 with two remotes (to simplify):

git remote -v

lib1  [email protected]:group1/lib1 (fetch)
lib1  [email protected]:group1/lib1 (push)
origin  [email protected]:main/project1 (fetch)
origin  [email protected]:main/project1 (push)

Please note that lib1 is another project.

I need to get the hash of the tag 5.344.45 that belongs to lib1.

When I run git show 5.344.45 I get the commit of the main project project1, clearly because both of the two projects have a tag with that name.

I tried git rev-list --remotes=lib1 --tags=5.344.45, but I get the hash of the commit that the branch refs/remotes/lib1/master refers to.

So the question is, how to tell this: please give me the commit of the tag 5.344.45 belonging to the remote lib1 ?

Upvotes: 0

Views: 63

Answers (1)

hobbs
hobbs

Reputation: 240571

You can git ls-remote lib1 refs/tags/5.344.45 (online operation).

You can also git fetch lib1 refs/tags/5.344.45, which will both set the symbolic reference FETCH_HEAD to be the commit that tag points to, and ensure that you actually have that commit and everything that it refers to downloaded. You can then do what you want with FETCH_HEAD.

Upvotes: 2

Related Questions