salv0 / git-old-branches-delete

Delete branches older than a specified time from the target git repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git old branches delete

The script deletes merged or non-merged branches older than a specified time from the target git repository, excluding the master branch automatically.

Usage info

The script runs as default in dry-run mode, so you can see what actions is going to take before performing a real execution specifying --execute.

Command:

git-old-branches-delete.sh [options] <repo-dir>

All the valid options are:

-d, --days               days [defaults to 91]
-m, --merged             delete merged branches [default]
-n, --no-merged          delete non-merged branches
-e, --execute            run the script pushing changes to git
-h, --help               show usage help

--debug                  show debug messages

Usage examples

Perform a dry-run deleting merged branches older than 91 days (three months):

git-old-branches-delete.sh /my/repository

Perform a dry-run deleting non-merged branches older than 91 days (three months):

git-old-branches-delete.sh --no-merged /my/repository

Perform a dry-run deleting merged branches older than 5 months:

git-old-branches-delete.sh --merged --days 152 /my/repository

(Note that --merged can be left out as it is the default value)

Perform a dry-run deleting merged branches older than 5 months and showing debug messages:

git-old-branches-delete.sh --debug --merged --days 152 /my/repository

(Note that --merged can be left out as it is the default value)

Perform a real execution deleting merged branches older than 5 months:

git-old-branches-delete.sh --days 152 /my/repository --execute

Quick days amount reference

Delete branches older than:

  • One year -d 365
  • Eight months -d 243
  • Five months -d 152
  • Three months -d 91
  • Two months -d 60
  • One month -d 30


Feedback

Suggestions and improvements welcome!

About

Delete branches older than a specified time from the target git repository

License:MIT License


Languages

Language:Shell 100.0%