Doesn't work when a branch contains commits that have been applied in more than one merge
ggilder opened this issue · 2 comments
ggilder commented
For example:
- I make a branch "develop-B" which is branched off "develop-A"
- "develop-A" is squash-merged into main branch
- "develop-B" is squash-merged into main branch
Now the approach this script uses (git cherry
) fails because there is not a single commit that matches the squashed commit representing "develop-B", it's spread across two commits.
I think that it's possible to fix this and simplify the script by using git merge-tree
and git merge-base
. Here's an example: https://github.com/ggilder/dotfiles/blob/master/bin/git-delete-merged-branches#L9
n8gray commented
@ggilder The approach you're taking in the script you link to won't work in general because it gets broken by subsequent work in the repo.
- make a branch
work
that modifies fileA
- squash merge it to
master
, but don't delete it - later merge a different branch to master that deletes file
A
Merging work
to master
at this point will produce a change. Your script would not consider work
eligible for deletion, but the one in this repo should.