Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.29 KB

File metadata and controls

44 lines (32 loc) · 1.29 KB

Git Worktrees

Worktrees allow you to check out multiple branches of the same repository in different directories simultaneously. This is perfect for when you need to quickly look at or fix something on another branch without stashing or committing your current work.

Add a new worktree

Create a new directory and check out a branch into it. #checkout-elsewhere #clone-local

git worktree add $path $branch

List active worktrees

git worktree list

Remove a worktree

When you are done with a worktree, you can remove it. This deletes the directory and the Git metadata tracking it. #rm-worktree

git worktree remove $worktree

Prune worktrees

If you manually delete a worktree directory using rm -rf, Git still thinks it exists. Use prune to clean up the internal metadata. #fix-worktree #clean-worktree

git worktree prune