Git

Git is a version control system. It is used for my notes collection to keep track of changes and preserve history. It also allows for accessible collaboration. Install Git by executing the following command:

sudo apt install git

Configuration

All the configuration for Git is stored in gitconfig files. See git identities for how to configure multiple Git identities.

Usage

A commit creates a snapshot of the current state of a Git repository. Git uses branches for collaborate work and diverging from the default environment. Worktrees can be used to switch between branches without committing or stashing changes.

Pull request

The rebase strategy is also a good option for pull requests. Do not squash commits or merge a pull request using the squash strategy, unless the commit messages are not providing any useful information. It is always better to leave as much history as possible for later debugging of code.

Other commands

Remove all references to remote branches that do not exist on the remote anymore:

git remote prune origin

Switch to the previously checked-out branch:

git switch -

This works the same as cd -, but for Git branches.

See also