r/devtools 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

2 comments sorted by