05 Apr 2023
Configure Git
See Pro Git if you are not familiar with Git.
1. Basic Configuration
1.1. Transfer Existed Configuration
- Copy the global git configuration file to
~/.gitconfig
. - Copy SSH keys to
~/.ssh/
. Add SSH key to
ssh-agent
.eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
1.2. First-Time Set up
See also Pro Git - Section 1.6
Set up your identity
git config --global user.name "John Doe" git config --global user.email johndoe@example.com
Set up default editor
git config --global core.editor vim
Set up default branch name
git config --global init.defaultBranch master
Set up git aliases
git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status
(Optional) Review your settings
git config --list --show-origin
- Set up SSH.
2. Add-ons
2.1. Prompt
bash-git-prompt: A bash prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.

2.2. Pager
delta: A syntax-highlighting pager for git, diff, and grep output.

3. An Example of .gitconfig
[user] name = John Doe email = johndoe@example.com [core] editor = code --wait pager = delta [init] defaultBranch = master [alias] a = add b = branch co = checkout ci = commit ca = commit -a cm = commit -m d = diff l = log --oneline -15 la = log --oneline --all -15 rb = rebase s = status last = log -1 squash = rebase --autosquash -i [interactive] diffFilter = delta --color-only [delta] light = true # set to true if you're in a terminal light background color side-by-side = true [merge] conflictstyle = diff3 [diff] colorMoved = default