01 Overview
Git tracks every change to a codebase as a graph of commits, letting teams branch, merge, and review work in parallel without stepping on each other. It underpins virtually every CI/CD and GitOps workflow.
→ official documentation02 Installation
Pick a platform. Each step is copy-pasteable on its own.
01 Update package index
sudo apt update
02 Install Git
sudo apt install -y git
03 Set your identity
git config --global user.name "Your Name" git config --global user.email "you@example.com"
04 Verify
git --version
01 Install Git
sudo dnf install -y git
02 Set your identity
git config --global user.name "Your Name" git config --global user.email "you@example.com"
03 Verify
git --version
01 Install via Homebrew
brew install git
02 Set your identity
git config --global user.name "Your Name" git config --global user.email "you@example.com"
03 Verify
git --version
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.
03 Install script
The steps above bundled into a single idempotent shell script for provisioning boxes unattended.
install-git.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
04 Cheatsheet
The commands reached for most often once Git is installed.
| Command | What it does |
|---|---|
| git status | Show changed and staged files |
| git switch -c feature/x | Create and switch to a new branch |
| git add -p | Interactively stage hunks |
| git commit -m "message" | Commit staged changes |
| git rebase -i HEAD~5 | Interactively edit the last 5 commits |
| git stash / git stash pop | Shelve and restore uncommitted work |
| git log --oneline --graph --all | Compact visual history of all branches |
| git bisect start | Binary-search commits for a regression |