This is an automated bash script to delete git branches older than some specific time period. The default set time is 4 months, but you can pass the period in months as a first parameter while running the shell script
- Navigate to your preferred directory
- Run terminal
- Type git clone https://github.com/LinuxEuphony/delete-old-git-branches to clone repository
- Navigate to the folder named delete-old-git-branches
To download and use this script:
- Click on
code
on this page. - Click on
Download Zip
. - A files named
delete-old-git-branches-main.zip
will be downloaded. Extract the zip file in your computer. You will see a folder labelleddelete-old-git-branches-main
. - Navigate to that folder.
- Navigate to and edit the file named
delete-old-git-branches.sh
. Replace the valueYOUR_REMOTE_OR_LOCAL_GIT_URL
on line13
with your remote/local git url. - Open the terminal inside the, or navigate through terminal into the folder named
delete-old-git-branches-main
- Type
chmod +x delete-old-git-branches.sh
and click onenter key
to make the script executable. - Type
./delete-old-git-branches.sh
to run the script.
- Below will run with the default 4 months period.
./delete-old-git-branches.sh
- Below will run with preferred timeline set.
./delete-old-git-branches.sh 3
- Below will run with default 4 months period and force delete unmarged branches enabled.
./delete-old-git-branches.sh -f
- Below will run with the preferred time set and force delete unmarged branches enabled.
./delete-old-git-branches.sh -f 3