gitbranchcommitgit-remotegit-tag

How do I get all refs that point to a commit in git?


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


Solution

  • git show-ref | grep $(git rev-parse HEAD) shows all refs that point to HEAD, the currently checked out commit.

    git show-ref shows all refs in your git repo.

    git show-ref | grep "SHA goes here" shows all refs that point to the SHA of a commit.