git

https://git-scm.com/

Install git

$ sudo apt install -y git
$ git --version
git version 2.34.1
$ sudo dnf install git
$ git --version
git version 2.27.0

git is pre-installed on macOS Monterey.

$ git --version
git version 2.37.1 (Apple Git-137.1)

To install a newer version:

$ brew install git
$ git --version
git version 2.46.0

Usage

Show config

$ git config -l

Set config

$ git config --global init.defaultBranch main
$ git config --global submodule.recurse true
$ git config --global push.recurseSubmodules check
$ git config --global url.git@github.com:.insteadOf https://github.com/
$ git config --global url.https://github.com/.insteadOf git@github.com:
$ git config --global pull.ff only
$ git config --global core.editor 'vi'

If you want to show unicode characters in filename:

$ git config core.quotePath false

Unset config

$ git config --unset pull.ff

See last commit

$ git log -p -1
$ git show

Briefly, only show names and status:

$ git show --name-status

Stash with untracked files

$ git stash --include-untracked
$ git stash -u

Clean

$ git clean -dxf

Find the common base of two branches

$ git merge-base develop main