I recently became an avid user of Git worktrees. However, the command line interface to them is about as great as Git command line interfaces always are. Just
git worktree add is a confusing maze of options.
I wrote a shell script to help myself and then I wanted to check parameters and then I decided that was a bridge too far with shell today and went for Swift instead.
My Worktrees tool has just one command for now, because that's the pain point I ran into today.
worktrees add-new-branch username/ mybranch main creates a new branch called
username/mybranch and a worktree called
mybranch for working on it, branching it off
main. You could very well argue that it's no easier than
git worktree add, but the idea is that I can define a repo-local alias for it. Almost all the branches I open are from the mainline branch of the repo I'm working in, and I want to prefix my branches with
juri/. So I can add this alias, if the repo is using
[alias] wta = !worktree add-new-branch juri/ main
And now running
git wta mybranch does opens me a new worktree the way I like it.