'github "Automatically delete head branches" for multiple repositories

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 flaxel