~/about/gist/git-worktree.md

Cari blog, catatan, dan gist

    ↑↓ navigate openesc close
    EN
    about/gist/git-worktree

    Git worktrees for parallel branches

    25 Jun 2026#git#workflow

    Instead of stashing to switch branches, check a branch out into a separate working directory:

    # create a new worktree for an existing branch
    git worktree add ../myrepo-hotfix hotfix
    
    # ...or a brand-new branch
    git worktree add -b feature/x ../myrepo-x
    
    # list and clean up
    git worktree list
    git worktree remove ../myrepo-hotfix

    Each worktree shares the same .git, so it’s cheap — no re-clone.