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 log with graph, oneline and all draws your branches in the terminal

Git
~/tips/tip-git-log-graph-oneline-all

git log --graph --oneline --all

Draws every branch and merge as a small text graph so you see how they relate.

You don’t need a GUI to see where branches split and merge. Three options to git log draw it right in the terminal.

git log --graph --oneline --all

--graph draws the lines on the left, --oneline keeps every commit to the short hash and subject, and --all includes every branch and tag instead of only the current branch. The output looks like this:

* ee66d74 feature work
| * dce17f9 main work
|/
* 6ae2e76 commit 5

Branch and tag names show up next to the commits, because git decorates the output when it goes to a terminal. In a script or pipe you have to ask for that with --decorate.

Since it is a lot to type, I’d put it in an alias. With git config --global alias.lg "log --graph --oneline --all", git lg does the same. You can still add things after it, like git lg -20 for the last twenty commits.

On a big repository with years of branches, --all turns into a wall of lines. Limit it with -n 30, or name only the branches I care about, like git log --graph --oneline main feature. Remote branches count as well, so a fetch with many stale ones makes the graph busier.

Further reading: git-log documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link