Open seanabraham opened 7 years ago
Sorry, hub sync
still doesn't recognize squash-merged branches! I'm not sure what would be the best way to support this, since it's not trivial to detect just by looking at git objects.
If anyone has any ideas, I'm all ears.
Is there a command I can run to get rid of that issue?
I copied a complicated git alias from somewhere that helps clean up squashed branches. It may or may not work for your use case:
[alias]
cleanup = "!git remote prune origin && git checkout -q master && git for-each-ref refs/heads/ '--format=%(refname:short)' | while read branch; do mergeBase=$(git merge-base master $branch) && [[ $(git cherry master $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == '-'* ]] && git branch -D $branch; done"
In my case, I run hub sync
followed by git cleanup
.
I am not familiar at all with hub's code, but perhaps this logic of looping over refs and comparing merges could be integrated into the sync
command?
I want to use
hub sync
to update local branches but more importantly delete branches that have been merged already via the Github UI. The problem is, when runninghub sync
I get many warnings like the following:warning: 'sean/branch_name' was deleted on origin, but appears not merged into master
.I'm assuming this is because the PR opened for this branch was merged using the "Squash and Merge" option so the SHA no longer matches. Is there a way to force
hub sync
to still delete branches in this case?