Basic Configuration

Git has three levels of configuration:

git config list shows all entries from all config files.

$ git config list
user.email=maschmi@maschmi.net
user.name=maschmi
init.defaultbranch=main
core.autocrlf=input
core.editor=nvim
alias.st=status --short
alias.sc=switch -c
alias.sb=switch -b
alias.sw=switch
pull.rebase=true
rerere.enabled=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=ssh://git@codeberg.org/maschmi/git-training.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

Git stores config value in a key value format.

$ cat /home/martin/.gitconfig
[user]
    email = maschmi@maschmi.net
    name = maschmi
[init]
    defaultBranch = main
[core]
    autocrlf = input
    editor = nvim
    defaultBranch = 123123
[alias]
    st = status --short
    sc = switch -c
    sb = switch -b
    sw = switch
[pull]
    rebase = true
[rerere]
    enabled = true

Config values can be set by supplying the value in the format `section.key value".

$ git config --global init.defaultBranch oneandonly
$> cat /home/martin/.gitconfig
[user]
    email = maschmi@maschmi.net
    name = maschmi
[init]
    defaultBranch = oneandonly
[core]
    autocrlf = input
    editor = nvim
    defaultBranch = 123123
[alias]
    st = status --short
    sc = switch -c
    sb = switch -b
    sw = switch
[pull]
    rebase = true
[rerere]
    enabled = true

Setting the editor

If you are not comfortable or familiar with the editor set in core.editor feel free to change it. In the example above it is set to neovim. Often it is set to vi or vim. A more easier to use editor may be nano