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 config --get-regexp finds settings by a pattern in the key

Git
~/tips/tip-git-config-get-regexp

git config --get-regexp '^user\.'

Lists every Git setting whose name matches a pattern, with its value.

The exact name of a Git setting is easy to forget, while a piece of it sticks. Scrolling through git config --list works, but there is a shorter way to search.

git config --get-regexp '^user\.'

The pattern is matched against the key, not the value, and every match comes out as key value. Quote the pattern so your shell leaves it alone. Handy ones are alias to list your aliases, ^remote\. to see all remotes, or color to find every colour setting.

One thing can look odd. The same key can show up twice, once from the global config and once from the repository’s local config. Git prints each value it finds, in order, and the later one wins. To see which is which, add --show-scope:

git config --get-regexp --show-scope '^user\.(name|email)$'

That puts global or local in front of each line. If you want the file path instead, --show-origin does that.

Caveat: when nothing matches, the command prints nothing and exits with status 1, so it isn’t an error message you’d notice by eye. It’s also handy to know that the output can include sensitive things like a signing key path or a credential helper, so look before you paste it into a bug report.

Further reading: git-config documentation

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

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