Add a config to exclude branches from deletion
mhdcodes opened this issue · 4 comments
Description
When sitting on a different branch than master, running a git trim -m
would delete master
& develop
branches.
I think a lot of projects still use the terminology of master
& develop
. So these branches should be protected by default.
Steps to reproduce
- Create a new branch from master or develop. The branch needs to be ahead of both
develop
&master
git checkout -b new-branch
git trim -m
- Results
Deleted branch develop (was 918b175e).
Deleted branch master (was 4a85d8ee).
Yes, as noted in the descriptions, this removes all except the current branch.
I do agree this is a bit nuanced. However, instead of trying to guess all the branch names one might want to keep, I think some kind of configuration file might be more robust. Something like a .git-trim
with branch names to keep.
# git trim excluded branches
master
develop
staging
Yes I think the config file is the best option, though I would allow for using that file for other configs, something like this
[protected]
master
develop
staging
[other-config]
After thinking on this more, I have piggybacked the Git configuration under the namespaced option of gt.exclude
.
It keeps the config contextual as a Git option instead of yet another project configuration file, and flexible to be set locally for a repo, or globally for your system.
That's a good solution. Because I was thinking the only way to allow for excluding per repo basis is using a config file.
So piggybacking on git config would seam for me the correct approach. good move.