Skip to content

git config

Open config in editor

Git config for current repo is not always in .git/config (e.g. when using submodules).

git config -e

Commands

  • Show config origin files: git config --list --show-origin

diff gpg

Update .gitattributes in repo:

echo "*.gpg filter=gpg diff=gpg" >> .gitattributes
echo "*.asc filter=gpg diff=gpg" >> .gitattributes

Tell Git to decrypt GPG files before diff'ing them (use --local for current repo only):

$ git config --global diff.gpg.textconv "gpg --no-tty --decrypt"
$

Don't ask me to run git push --set-upstream origin. Rather than ask me where to push new branches:

git config --global push.default current

Disable gpg signing for current repo

git config --local commit.gpgsign false

Override $EDITOR for commits

Don't use code for commits.

git config --global core.editor "vim"

Global user config

--global

For writing options: write to global ~/.gitconfig file rather than the repository .git/config, write to $XDG_CONFIG_HOME/git/config file if this file exists and the ~/.gitconfig file doesn’t.

For reading options: read only from global ~/.gitconfig and from $XDG_CONFIG_HOME/git/config rather than from all available files.