Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Git Config(s)

System level

Applied to every user on the system and all their repositories.

Global User level

Specific personally to you, the user.

Stored in any one of:

Repository level

Specific to that single repository.

Set repo-specific (non-global) config settings:

git config user.name "Alex Sokolsky"
git config user.email "asokolsky@gmail.com"
git config core.sshCommand "ssh -i ~/.ssh/private_key"

Make sure your private identity is available:

ssh-add ~/.ssh/private_key

Then

git remote add origin git@github.com:asokolsky/repo.git
git push --set-upstream origin master

View All Settings

Show system, global, and (if inside a repository) local configs:

git config --list

To also show the origin file of each config item:

git config --list --show-origin

To get e.g. user.name:

git config user.name

You may also specify options --system, --global, --local to read that value at a particular level.

Best Practices - Global Config

Followed:

git config --global user.name "Alex Sokolsky"
git config --global user.email "asokolsky@gmail.com"
git config --global core.editor /usr/bin/emacs
git config --global core.excludesfile ~/.gitignore
git config --global core.pager ''
git config --global push.default current

where ~/.gitignore:

*~
.*.swp
.DS_Store

Example ~/.gitconfig:

# a matter of taste (uncomment if you dare)
[branch]
    # sort = -committerdate
    sort = committerdate
[column]
    ui = auto
[commit]
    verbose = true
[core]
    # fsmonitor = true
    # untrackedCache = true
    editor = emacs
    excludesfile = ~/.gitignore
[diff]
    algorithm = histogram
    colorMoved = true
    # colorMoved = plain
    mnemonicPrefix = true
    renames = true
[feature]
    experimental = true
[fetch]
    all = true
    prune = true
    pruneTags = true
[grep]
    patternType = perl
[help]
    autocorrect = prompt
[init]
    defaultBranch = main
[merge]
    # just 'diff3' if git version < 2.3
    conflictstyle = zdiff3
[pull]
    rebase = true
[push]
    default = simple
    autoSetupRemote = true
    followTags = true
[rebase]
    autoSquash = true
    autoStash = true
    updateRefs = true
[rerere]
    enabled = true
    autoupdate = true
[tag]
    sort = version:refname