fix: make git merge2 work across worktrees

Checkout of the target branch fails when it is already used by another
worktree. Detect that worktree and merge there instead.
This commit is contained in:
2026-09-10 23:04:13 +08:00
parent a834c46b89
commit 097fce7827
2 changed files with 74 additions and 1 deletions
+2 -1
View File
@@ -73,7 +73,8 @@
pt = push origin --tags
ph = push origin HEAD
pht = push origin --tags
merge2 = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout $1 && git merge $_CURRENT_BRANCH && git checkout $_CURRENT_BRANCH' -
# 把当前分支合进目标分支后回到当前分支;目标已被其它 worktree 占用时在那边 merge
merge2 = !$HOME/.dotfile/git/git-merge2.sh
bg = "!f() { git branch | grep $1; }; f"
delbr = "!f(){ git branch -D $(git branch | grep \"\b$1\"); };f"
can = commit --amend --no-edit