[ t128n ]

Git Cheatsheet

Quick reference for common Git commands and workflows.

Switching Branches

For existing branches:

Terminal window
git switch <branch-name>

To create new branches:

Terminal window
git switch -c <new-branch-name>

Read more about git switch vs. git checkout.

Manual reference: git switch.

Working with Worktrees

List all attached worktrees:

Terminal window
git worktree list

Create a new worktree for a branch (creates the branch if needed):

Terminal window
git worktree add -b <new-branch-name> ../<folder-name>

Create a worktree for an existing branch:

Terminal window
git worktree add ../<folder-name> <branch-name>

Remove a worktree when done:

Terminal window
git worktree remove ../<folder-name>

Clean up stale worktree metadata:

Terminal window
git worktree prune

Manual reference: git worktree.