brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git show-branch shows which commits sit on which branch

Git
~/tips/tip-git-show-branch

git show-branch main feature

Shows in one table which commits are on which branch since they split.

When two branches have drifted apart, git log makes me run a few commands to see how. git show-branch puts it in one small table.

Give it the branches you want to compare:

git show-branch main feature

The first lines, before the -- separator, list the branches, one column each. Below that is one line per commit, newest first. A + or * in a column means the commit is on that branch (the * marks the branch you have checked out). A - marks a merge commit. The list stops at the commit where the branches share history, so you see exactly what each side added since they split.

A few options I’d keep in mind:

git show-branch --more=3 main feature
git show-branch -a

--more=3 shows three more commits past the common ancestor for context, and -a includes remote-tracking branches.

A caveat: the column layout gets hard to read with more than a handful of branches, and the names with ~ and ^ in the output are relative to the branch tip. For a quick picture of a messy history, git log --graph --oneline is easier on the eyes. I’d reach for show-branch when the question is simply what is on one branch and not on the other.

Further reading: git-show-branch documentation

More Git tips git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort git branch --edit-description [<branch-name>] All Git tips (144) All topics

Link