是否有任何工具/技巧可以改善此工作流程:
⋊> on master ◦ git branch -d add_code_to_import_from_mew
error: The branch 'add_code_to_import_from_mew' is not fully merged.
If you are sure you want to delete it, run 'git branch -D add_code_to_import_from_mew'.
⋊> on master ◦ git checkout add_code_to_import_from_mew Switched to branch 'add_code_to_import_from_mew'
⋊> on add_code_to_import_from_mew git rebase master
First, rewinding head to replay your work on top of it...
⋊> on add_code_to_import_from_mew git checkout master 21:13:22
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
⋊> on master ◦ git branch -d add_code_to_import_from_mew 21:13:33
Deleted branch add_code_to_import_from_mew (was ed05c05).
我不想使用“-D” - 只想在没有变化的情况下删除
答案 0 :(得分:2)
以下(POSIX兼容)脚本将删除对master
具有空差异的所有本地分支:
#!/usr/bin/env sh
git for-each-ref --format='%(refname:short)' refs/heads | \
while read ref; do
test $ref != master && \
git diff-tree --quiet $ref master && \
git branch -D $ref
done
谨慎使用! master
的空差异并不意味着分支在master
中完全合并!