Create new branch for worktree if it doesn't exist
This commit is contained in:
@@ -33,7 +33,11 @@ Manage git worktrees by branch name."
|
|||||||
add)
|
add)
|
||||||
local root=$(git rev-parse --show-toplevel)
|
local root=$(git rev-parse --show-toplevel)
|
||||||
local wt_dest=${root:h}/${root:t}@${branch}
|
local wt_dest=${root:h}/${root:t}@${branch}
|
||||||
git worktree add "$wt_dest" "$branch"
|
if ! git show-ref --verify --quiet refs/heads/"$branch" && \
|
||||||
|
! git show-ref --verify --quiet refs/remotes/origin/"$branch"; then
|
||||||
|
git branch "$branch" origin/main || return 1
|
||||||
|
fi
|
||||||
|
git worktree add "$wt_dest" "$branch" || return 1
|
||||||
if [ -f $root/.enter ] && [ -f $root/.exit ]; then
|
if [ -f $root/.enter ] && [ -f $root/.exit ]; then
|
||||||
ln -s $root/.enter $wt_dest/.enter
|
ln -s $root/.enter $wt_dest/.enter
|
||||||
ln -s $root/.exit $wt_dest/.exit
|
ln -s $root/.exit $wt_dest/.exit
|
||||||
|
|||||||
Reference in New Issue
Block a user