https://github.com/frops/git_remove_branches
The script deletes interactively old branches of your git-repository
https://github.com/frops/git_remove_branches
git git-flow
Last synced: about 1 month ago
JSON representation
The script deletes interactively old branches of your git-repository
- Host: GitHub
- URL: https://github.com/frops/git_remove_branches
- Owner: frops
- License: mit
- Created: 2018-09-18T12:59:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-16T10:10:34.000Z (over 2 years ago)
- Last Synced: 2025-01-29T14:39:27.722Z (10 months ago)
- Topics: git, git-flow
- Language: Shell
- Homepage:
- Size: 3.91 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[**DEPRECATED**] Use git commands for delete merged branches instead of this code
## Git commands:
Original issues: https://stackoverflow.com/questions/6127328/how-do-i-delete-all-git-branches-which-have-been-merged
Code:
```
git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d
```
It delete all merged branches in the master|main|dev branches.
---
### Remove old branches
The script deletes old remote and local branches of your git-repository in interactive mode
#### Usage
##### Linux
Just run script.sh
~~~~
./script.sh
~~~~
Each time a confirmation is requested to delete a branch.
Press enter for delete branch or any symbol for cancel.
You may specify `exit` for stop script.
~~~~
Branch: origin/some_branch, Created At: 2017-05-26 Author: frops
Are you sure to delete remote branch some_branch? [press any symbol for cancel or just enter for delete]
exit
Exited
~~~~
##### Mac OS / Windows
Use **Docker** and run as in Linux
~~~~
docker run -v $(pwd):/app frops/git_remove_branches ./script.sh -m 12
~~~~
##### Params
`-m|--month` – age of making branches in the months you want to delete
`-f|--force` – the force mode, in which branches are deleted without confirmation. Please, be careful. I'am not recomended use this command. Use it in exceptional cases!
##### For example
Delete branches older then 6 month:
~~~~
./script.sh
~~~~
Delete branches older then 24 month (2 years):
~~~~
./script.sh -m 24
~~~~
Delete branches older then 6 month in **force mode**.
**Please, be careful with this command.**
~~~~
./script.sh -f
~~~~