diff --git a/worktree.sh b/worktree.sh new file mode 100644 index 0000000..b8a2b36 --- /dev/null +++ b/worktree.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +repo=$1 +dir="${repo##*/}" +dir="${dir%.*}" +echo $dir +branch=$2 +defaultBranch="${branch:-main}" + +mkdir -p $dir +cd $dir + +git clone --bare $repo .bare +echo "gitdir: ./.bare" > .git +echo " fetch = +refs/heads/*:refs/remotes/origin/*" >> ./.bare/config + +git worktree add $defaultBranch