Reputation: 39519
Is there any tool/trick to improve this workflow:
⋊> 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).
I do not want to use "-D" - just want to delete when there are no changes
Upvotes: 0
Views: 67
Reputation: 66224
The following (POSIX-compliant) script will delete all local branches that have empty diffs against 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
Use with caution! An empty diff with master
doesn't imply that the branch is fully merged in master
!
Upvotes: 2