git show-ref

List all references (branches and tags) and their commit hashes.

This command is useful for quickly viewing all references in a Git repository, such as branches and tags, along with the commit hashes they point to, which helps in identifying the current state and structure of the repository.

It works by scanning the .git/refs directory and displaying each reference and its corresponding SHA-1 hash, making it easy to see what commit each branch or tag is associated with.

You can use git show-ref --heads to show only branch references, or git show-ref --tags to show only tag references; adding -q suppresses output if no references are found, and -s shows only the SHA-1 hashes.

Other related commands include git branch -v for branch names and their latest commit, and git tag -n for tag names with annotations, but these do not show both branches and tags together like this command does.

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...