Skip to content

Git basics

Last updated:

For anyone joining a team that keeps its code in Git. Six short pages, commands first, only what you will use in your first month.

  • Set up Git: install Git, tell it who you are, and set three defaults that prevent common confusion.
  • The daily loop: clone, see what changed, commit, share, update.
  • Branches and pull requests: one change per branch, a pull request to merge it, and what to do after the merge.
  • Fix mistakes: nine situations you will hit, the command that fixes each, and why it is safe.
  • What not to commit: secrets, build output, editor files, large binaries, and line endings.
  • Large files with Git LFS: when a file belongs in Git LFS, how to track it, and how to move existing files there.

Skipped on purpose: submodules, interactive rebase, bisect, hooks, commit signing, git flow, LFS locks, and rebasing to update a branch. You will know when you need them. The Pro Git book covers each one.

Every command on these pages runs in an automated test before it is published.

Git basics is licensed under CC BY 4.0: copy it, adapt it, keep the credit.