On Github we can set automatically deletion of branches after merge for a repository (like explained here). I want to do this for 30 repositories. Is there a way to do this by script ? I typically would like to add a file to each repository.
Asked
Active
Viewed 540 times
1 Answers
2
I think you can do this relatively easily with a script. You can use the GitHub CLI for this. There is the following command with which you can switch on the deletion of the branch after a successful merge for a repository:
gh repo edit [<repository>] --delete-branch-on-merge
If you want to start with the CLI, I guess this is a good starting point.

flaxel
- 4,173
- 4
- 17
- 30
-
```for repo in `gh repo list | awk '{print $1}'` ; do gh repo edit $repo --delete-branch-on-merge ; done``` – Morten Feb 20 '23 at 20:49