drew
drew

Reputation: 3157

Which git branches point to the current commit?

Currently, if I want to know the branches that point at the current commit, I use

git show-ref | grep "<SHA1>"

Where <SHA1> is the current commit.

This produces output like

<SHA1> refs/heads/branch-name1
<SHA1> refs/heads/branch-name2
<SHA1> refs/remotes/origin/branch-name1

Is there a simpler way to get the branches that point to the current commit? Something similar to

git-ideal-command-without-parameters

Which produces

branch-name1
branch-name2
origin/branch-name1

?

Upvotes: 3

Views: 117

Answers (1)

Schwern
Schwern

Reputation: 164639

git branch --points-at HEAD

HEAD is a reference to the currently checked out commit.

See git-branch for more information.

Upvotes: 4

Related Questions