Git topic
Branching and merging
Learn how to work with branches and merge your changes together.
Look it up and watch it run
From the Animated Git Cheat Sheet
23 commands on this topic, each drawn by git-sim on a small sample repository.
git branch <name>
List all branches, remote ones too
git branch -a
See which branches are ahead or behind
git branch -vv
List branches that are safe to delete
git branch --merged
List branches with unmerged work
git branch --no-merged
Switch branches
git switch <branch>
Switch back to the previous branch
git switch -
Check out a teammate's branch
git switch <branch>
The commands, played on a real repository
Pick a command to watch it happen. Each one shows its risk rating; the ones with a full page link to the before and after, whether it is safe, and how to undo it.
How to use this page
- slider / ▶Drag the slider, or press play, to watch the command happen. Before and After jump to either end.
- ← → · spaceStep through a multi-step command; space toggles Before / After.
- APlay or pause the loop (the page opens playing). Any manual input takes over.
- hoverA commit shows its message, author, date and parents, with its history highlighted.
- clickCopies the commit sha.
- ctrl + wheelZoom around the cursor (pinch on a trackpad). Double-click resets the view.
- EscStop playback, reset the view, close this menu.
- shareThe Share button copies a link to this graph, copies it as an image, downloads PNG/SVG/page, or posts it. #before, #after or #step=N in the link pins the state.
Pick a command to watch it happen on a small sample repository.
git
safe
Sample repository: . Drag the slider or press play; hover a commit for its details.
Read the full page
Practice it in Level 1
Try it on your own repository: git-sim
Every command plays on the same repository, so they are easy to compare.
No command matches that. Try a shorter word, or another danger level.
- Safe reads or only adds; nothing is lost
- Caution moves or rewrites things; recoverable from the reflog
- Destructive can lose work for good
Watch them in the git-sim viewer
Each demo plays step by step, with the before and after side by side.
git branch <branch>git switch -c <branch>git checkout <branch>git merge <branch>git branch -D <branch>git worktree add <path> <branch>
Every command in one place: the Visual Git command reference.
Learn how it works
Levels on this topic
Watch each command happen, step by step, then pick the right one yourself.
- 7 Level 7 Branch & switch Create a new branch, switch between branches, and watch two storylines split apart.
- 8 Level 8 Merge Merge one branch into another, and learn when Git creates a merge commit versus fast-forwarding.
- 15 Level 15 Detached HEAD Point HEAD at a commit with no branch, understand why it is useful, and get back out safely.
Workflow demos
A few commands in a row, the way you'd use them on a real project.
Try it in your own repos
git-sim
See what a command will do to your repo before you run it. It reads the repository and draws the result without changing anything.
git-sim switch -c <branch>git-sim merge <branch>git-sim branch -d <branch>
It can also pre-flight a risky command as you type it, and follow your repo live while you or an AI agent work in it.
git-dummy
Make a throwaway repo shaped for this topic, then practice on it without risking real work.
git-dummy --commits=6 --branches=2 --name practicegit-dummy --scenario merge-conflict --name practice
Then cd practice and run any of the git-sim commands here.
Want to see your repo a whole new way? Devlands turns it into a 3D world you can walk through.




