How to get all links pointing to commit in git?

Is there a way to get a list of links (including tags, branches and remotes) that point to a specific commit in git?

+4
source share
2 answers

git show-ref | grep $(git rev-parse HEAD) git show-ref | grep $(git rev-parse HEAD) shows all links pointing to the HEAD that is currently committed to the commit.

git show-ref shows all the links in the git repository.

git show-ref | grep "SHA goes here" git show-ref | grep "SHA goes here" shows all links pointing to SHA commits.

+5
source

Human readable format

For the last commit (i.e. HEAD):

 git log -n1 --oneline --decorate 

Or specify a specific commit:

 git log -n1 --oneline --decorate fd88 

gives:

fd88175 (HEAD -> master, tag: head, origin/master) Add diff-highlight and icdiff

To get only the / refs / remotes tags, pass this through sed :

$ git log -n1 --oneline --decorate | sed 's/.*(\(.*\)).*/\1/'

HEAD -> master, tag: head, origin/master

For bonus points, add an alias for this:

 decorations = "!git log -n1 --oneline --decorate $1 | sed 's/.*(\\(.*\\)).*/\\1/' #" 
+1
source

Source: https://habr.com/ru/post/1488361/


All Articles