简体   繁体   中英

What does ^{} mean in git?

I stumbled upon two odd characters at the end of a git ls-remote command and I wonder what this means?

0e4c39557ccb6789173c  refs/tags/2011-11-04
966f8df553f18c486820  refs/tags/2011-11-04^{}

Do you happen to know what this ^{} means? Also, why does this git tag seems duplicated?

The ^{} notation is explained in the gitrevisions manual:

<rev>^{}, e.g. v0.99.8^{} 

A suffix ^ followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.

In this case - refs/tags/2011-11-04 is the tag that points to the tag object 0e4c39557ccb6789173c . By doing refs/tags/2011-11-04^{} we can dereference the tag to the final non-tag object, which in this case is - 966f8df553f18c486820 (a commit). Note that ^{} is a noop when applied to non-tag objects.

The git show-ref command can be use to see tags as well as the final dereferenced non-tag objects:

$ git show-ref --tags
3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}

$ git show-ref --tags --dereference
3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}
055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4
423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}

From the git show-ref manual:

-d 
--dereference 

Dereference tags into object IDs as well. They will be shown with "^{}" appended.

Note that git ls-remote has new filter with git 2.8 (March 2016).

See commit 99c08d4 , commit ba5f28b , commit 80b17e5 , commit 40a8852 , commit 54813bd (18 Jan 2016) by Thomas Gummerer ( tgummerer ) .
Suggested-by: pedro rijo ( pedrorijo91 ) .
(Merged by Junio C Hamano -- gitster -- in commit bd6934a , 03 Feb 2016)

That means you can show only the tags with

git ls-remote --refs

Do not show peeled tags or pseudorefs like HEAD in the output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM