$ ll ~/work/analytical-solutions-trees drwxrwsr-x 81 bprew rtk 8.0K Nov 15 17:36 faster-rap-tags drwxrwxr-x 82 bprew rtk 8.0K Sep 11 22:27 master drwxrwsr-x 81 bprew rtk 8.0K Nov 13 16:20 migrate-as-linear-to-vpc
I have a git script named "start" that I use when I want to add a new worktree
ex. (in master/) git start geomap
That creates a new worktree and cd's into it.
#!/bin/bash
BRANCH_NAME=personal/$USER/$1
WORK_DIR=../$1
# cleanup old remote branches
git remote prune origin
git checkout master
git pull --ff-only
git worktree add -b $BRACH_NAME $WORK_DIR
# move to newly created work directory
cd $WORK_DIR
# push and set upstream
git push -u origin $BRANCH_NAME
# make sure there's not outstanding changes in the tree
git status
# remove the directory
rm -rf ../<worktree>/
# cleanup worktree list
cd master && git worktree prune