Developer: Dusan Malusev dmalusev@nanointeractive.com
In my current company i was working on some legacy project, which had a lot of old git branches, many of them must be deleted from the repository. This branches
are just garbage, they were merged a long time ago, but there is not easy way to know how old were this branches, when was the last commit on them, etc.
I sat down one night and came up with this tool, git-branch-deleter
. It displays all remote and local branches and asks what to do with the currently displayed branch. (Keep, Remove, Show Commit message, etc.)
--path
(aliasesrepo, repository, project
) Path to the repository where this actions will be performed. On unix systems paths are case sensitive. (Environmental VariableGIT_BRANCH_DELETER_REPO_PATH
)--skip
(aliasesomit
) Branches to skip - defaults tomaster
(Environmental VariableGIT_BRANCH_DELETER_SKIP_BRANCHES
)--filter
Filters the branches based on the localitylocal, remote, both
. defaults toboth
.--ssh-key
(aliaseskey, ssh
) Path to the SSH key used for authentication to remote git repository. (Environmental VariableGIT_BRANCH_DELETER_SSH_KEY
)
# Execute on the current project
$ git-branch-deleter # No arguments needed
# Use the ssh key to remove only remote branches
$ git-branch-deleter --ssh-key /home/username/.ssh/id_ed25519 --filter remote --path /path/to/project
# Skip the branches in the output
$ git-branch-deleter --ssh-key /home/username/.ssh/id_ed25519 --filter remote --skip origin/master,develop,feat/some-other-branch