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 with show-origin tells you which file a setting comes from

Git
~/tips/tip-git-config-show-origin

git config --show-origin --list

Shows the file behind every git setting, so you know where to change it.

Git reads settings from several files: system, global, the repository itself and anything included from those. When a setting behaves oddly, the first question is where it’s set.

git config --show-origin --list

Every line now starts with the file it came from:

file:/home/alice/.gitconfig    [email protected]
file:.git/config               core.filemode=true

For one setting, ask for it by name. --show-origin works with a single key too, and --show-scope adds whether it’s system, global, local or worktree:

git config --show-origin --show-scope --get-all user.email

I’d use --get-all because a key can be set in more than one file. The last one wins, and seeing all of them explains why your global setting seems to be ignored: the repository’s own .git/config overrides it.

This is especially helpful with includeIf rules, where a work config gets pulled in only for certain folders. The origin shows the included file, so you can tell whether the rule matched at all.

Settings that come from environment variables, like GIT_AUTHOR_EMAIL, or from -c on the command line show up as command line: or not at all, because they’re not in a file. If the origin list looks right but git still does something else, check your environment with env | grep GIT_.

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