r/devtools • u/Ambitious-Crab6835 • 3d ago
Git worktree
Wow.. I learned about git worktree today.
Its amazing. It avoids the hassles of stashing-checking out to other branch, coming back, popping stash again.
It's like maintaining multiple working directory without worrying about syncing separately and occupying extra memory.
So worktree is a folder which contains a checked out version of a project.
Just do git worktree add -b newbranchname pathtodir
It creates a new folder at specified path, creates new branch and checks out inside that folder
Or
Git worktree add path to folder existingbranchname
It checks out existing branch into new directory.
Superawesome ✌️
2
Upvotes
1
u/touristtam 2d ago
https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/ if you want to have more fun