git-show-branch
Visualize branch relationships and commit history
TLDR
Show a summary of the latest commit on a branch
Compare commits in the history of multiple commits or branches
Compare all remote tracking branches
Compare both local and remote tracking branches
List the latest commits in all branches
Compare a given branch with the current branch
Display the commit name instead of the relative name
Keep going a given number of commits past the common ancestor
SYNOPSIS
git show-branch [--topic] [--independent] [--date-order] [--list] [--merge-base] [--stdin | <rev>...]
PARAMETERS
-r, --rev-output-reverse
Show commits in reverse order of output.
-g, --more
Show more commits than the default limit (usually 20). Can be specified multiple times.
-a, --all
Show all refs, not just heads.
-c, --color
Show colored output (default is to use color when outputting to a TTY).
--no-color
Turn off colored output, even if default is color.
-i, --independent
Show only branches that are not merged into any other specified branches.
-t, --topic
Show only topic branches (those not merged into any other specified branch).
-s, --sparse
Show a more concise output, omitting commit messages and focusing on ancestry.
-m, --merge-base
Find and show the common merge base of the specified revisions.
--list
List the branches that contain current HEAD, or the given revision if specified. Does not show history.
--stdin
Read revisions from standard input, one per line.
--date-order
Sort commits by commit date. Default is topological order.
--topo-order
Sort commits by topological order (parent before child). This is the default.
--no-name
Do not show branch names in the output.
--sha1-name
Show SHA1 of the branch head instead of the name.
--current
Mark the current branch (HEAD) specially in the output.
--reflog
Include reflog entries in the displayed revisions.
<rev>...
Specify one or more revisions (e.g., branch names, commit SHAs) to display. If none are specified, all local heads are shown.
DESCRIPTION
The git-show-branch command is a powerful tool for visualizing the commit ancestry of multiple branches, making it easier to understand how they diverge and merge. It displays a summary of the commits on the named branches that are not found on the default branch (or common ancestor).
Instead of showing a linear log, git-show-branch provides a columnar output, where each column represents a specified branch. Commits are marked with symbols to indicate their presence and relationship:
! indicates the tip of a topic branch.
* indicates a common commit reachable from multiple branches.
+ indicates a commit unique to a specific branch.
(space) indicates the commit is not present or not unique to that column.
It's particularly useful for reviewing proposed merges, identifying commits unique to a feature branch before integration, or understanding complex repository histories with many active branches.
CAVEATS
The output of git-show-branch can become dense and difficult to read when dealing with a very large number of branches or a deep commit history. Its primary strength lies in visualizing divergence from a common ancestor, rather than a full chronological log of all commits. For detailed commit information, git log is more appropriate.
OUTPUT FORMAT
The output uses a specific format to convey information:
Each column represents a specified branch.
An ! in a column indicates the tip of that branch.
A * indicates a common commit reachable from multiple specified branches.
A + indicates a commit unique to the branch represented by that column.
A blank space indicates the commit is not reachable from that branch or is not unique to it.
The commit subject line is preceded by the names of the branches whose tips are ancestors of the commit and, if applicable, the commit SHA-1 (if --sha1-name is used) and a short summary of the commit message.
EXAMPLES
git show-branch master develop feature/x
Shows the commits on 'master', 'develop', and 'feature/x' branches, highlighting their common history and unique commits.
git show-branch --merge-base HEAD origin/master
Displays the common merge base commit between the current HEAD and 'origin/master'.
git show-branch --list
Lists all branches that contain the current HEAD commit.
HISTORY
The git-show-branch command has been a fundamental part of Git since its early days, addressing the crucial need for developers to visually understand the relationships and divergence points between different lines of development. Its design emphasizes a clear, column-based representation of commit ancestry, making it an invaluable tool for complex branching workflows, even as other visualization tools have emerged.
SEE ALSO
git log(1), git branch(1), git merge-base(1), git diff(1)