What is git worktree, and how does it allow you to work on two branches simultaneously without two clones?

Last updated 6 July 2026

  • git worktree gives one repository multiple working directories, each on a different branch, sharing the same .git objects and refs.

  • git worktree add ../hotfix hotfix creates a new checkout without duplicating history, avoiding stashing WIP when switching tasks.

  • A branch can't be checked out in two worktrees at once. Clean up with git worktree remove and git worktree prune.

  • https://www.reddit.com/r/cscareerquestions/comments/bxxwfc/what_are_some_behavioral_questions_you_have_been/
  • https://www.reddit.com/r/rails/comments/1shfrbq/3_years_rails_dev_but_failed_basic_interview/
  • https://www.reddit.com/r/cscareerquestions/comments/u7z2xh/how_often_do_developers_look_at_git_trees/
All Git interview questions