Practical Git guide

Use Git worktrees to work on two branches at once

Create a second checkout with git worktree, keep pending edits separate, and inspect both branches safely.

Before you start

You have unfinished edits on main and need a separate feature checkout. Linked worktrees share repository history and refs while keeping working files and indexes separate. They are not separate clones or automatic isolation of application services.

Use Git 2.28 or newer in a POSIX shell on macOS/Linux, or Git Bash on Windows. Check git --version; Git's installation page covers setup. Each example starts in a new temporary folder. Keep that folder if you want to revisit your work; none of these commands removes your existing projects. The identity and signing settings below apply only to the practice repository.

Work through the example

practice=$(mktemp -d "${TMPDIR:-/tmp}/gitglow-learn.XXXXXX")
sandbox="$practice/project"
mkdir "$sandbox"
cd "$sandbox"
git init -b main
git config --local user.name "Git Learner"
git config --local user.email "learner@example.invalid"
git config --local commit.gpgsign false
printf 'A small project\n' > notes.txt
git add notes.txt
git commit -m "Start notes"
printf 'Unfinished main edit\n' >> notes.txt
git worktree add -b feature/parallel ../parallel
git worktree list
cd ../parallel
cat notes.txt
printf 'Parallel feature\n' >> notes.txt
git add notes.txt
git commit -m "Add parallel feature"
git status --short
cd "$sandbox"
git status --short
cat notes.txt

Check the result

The parallel worktree starts from main’s committed snapshot, so it does not inherit the unfinished main edit. Its feature commit does not change main’s working file. main still shows an unstaged modification; the feature worktree is clean. The sibling path stays inside the parent temporary directory.

Try it yourself

Inspect git log --all --graph --oneline from either checkout. After reviewing the clean feature worktree, optionally remove that checkout with git worktree remove ../parallel; the feature branch remains. Do not force removal of dirty work.

If something goes wrong

If Git says a branch is already checked out, choose another branch or use its existing worktree. If the destination exists, choose a new unused path. Each checkout needs its own dependency/build setup; shared ports and external services are not isolated by Git.

Use this workflow in GitGlow

Use GitGlow’s repository/worktree context to open the exact checkout and confirm its branch before editing. Free can inspect an existing trusted checkout; Pro adds managed worktree creation and concurrent workspaces. The Free terminal supports the command-line creation shown here. Dirty worktrees are not automatically removed.

Download GitGlow Free

Go deeper with the official Git docs

These references cover command options and behavior beyond this example.