Ram Rachum
Ram Rachum

Reputation: 88718

Git command to show the value of a branch

I'm looking for a git command like this:

git show-branch-value refs/heads/master
cf574d699a8bd67fc0b851cda3452c4d18c4223540a

What I want it to do is show the value of the selected branch.

Is there such a command?

Upvotes: 2

Views: 60

Answers (2)

Adam Dymitruk
Adam Dymitruk

Reputation: 129762

You can use

git rev-parse refs/heads/your-branch

or on remote branches

git rev-parse refs/remotes/origin/some-remote-branch

But you can also just cat the file (if it hasn't been packed - see comment by Dmitry below):

cat .git/refs/heads/your-branch

Upvotes: 1

Matthew Flaschen
Matthew Flaschen

Reputation: 285047

You can use:

git rev-parse refs/heads/master

This works for anything (branches, tags, SHAs).

Upvotes: 0

Related Questions