• Ethan@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 months ago
    • Scenario: I’m in the middle of writing a new feature.
    • Boss, to me: “Shit broke. Go figure it out.”
    • Me, thinking: I’m in the middle of doing some complex work. If I commit/stash and close the open files, it will take a day for me to remember WTF I was doing.
    • Me: “Oh look, worktrees! I can leave my workspace intact with all the files open, pending changes, test results, terminal output, everything! And just create a new worktree to checkout the production version and debug! I’m saved!”

    Also setting up a worktree is really easy. git worktree add ../hotfix prod-branch && cd ../hotfix and get working. Though in reality it’s cd ../hotfix && git checkout prod-branch because I’ve never needed more than one secondary worktree.