coderef

Git Branching

Learn Git by watching it work. Type real commands — commit, branch, merge, rebase, cherry-pick — and see the commit graph animate. Work through the levels, or experiment in the sandbox.

Your repository

C0: Initial commitC0C1: Add README (parent C0)C1main*

Goal

C0: Initial commitC0C1: Add README (parent C0)C1C2: Quick commit (parent C1)C2C3: Quick commit (parent C2)C3main*
$

How to use

Type commands in the terminal (↑/↓ for history; separate several with ;). Click a command below to put it in the terminal. Commits are labelled C0, C1…; copies made by rebase, revert or cherry-pick get a prime (C2′). Faded commits are no longer reachable from any branch. After git clone, origin's graph appears beside yours and dashed origin/… labels show where it was at your last fetch.

Commits & branches

Moving around

Combining work

Remotes

Inspecting

Refs

  • HEADThe commit you're on
  • main^Parent of main
  • HEAD~33 commits back
  • C5^2Second parent of a merge
  • origin/mainWhere origin's main was at last fetch
  • HEAD@{2}Where HEAD was 2 moves ago (reflog)
  • main..featureCommits in feature but not main
  • C3A commit by id

Playground

  • undoUndo the last command
  • resetRestart the level / sandbox
  • clearClear the terminal
  • helpList commands