Automate creation of repository and branches

I would like to know, is there any possibility of automated scripts, which will help us to setup the Repository and branches specified?
For example,
A script that can be executed by reading following information from a properties file and create a repository named “MyProject” and also create five branches named dev1, dev2, test, preprod, prod.

git_repo_setup.properties:

repo=MyProject
branches=dev1, dev2, test, preprod, prod

Also, be able to push the base setup files into “master” branch. Including the support for Large File size
Please check and let me know if this is possible.
Thanks
Vamshi

Hi @vamshidharkibm,

Thank you for being here!  It is possible to automate the creation of repositories by using one of the two create API end points.

Depending on your use case, you may also find webhooks useful. For instance, you could use a webhook to create a new repository whenever an issue is created requesting one.

2 Likes

Thank you @andreagriffiths11 

I’m new to REST APIs; Can anyone provide a way how can I use them?

Can I use them from a Java Program or does it work only shell script?

Is there any sample code snippet?

Below is what I tried from Terminal, but branch is not created


curl -i -H “Authorization: token <my_token>” \
-d ‘{ \
“name”: “my_branch_name”, \
“auto_init”: true, \
“private”: true, \
“gitignore_template”: “nanoc” \
}’ \
https://github.com/<mygit>/<myrepo>git


Thanks

Vamshi

Hi,

I’m able to use it in the following way

curl -u $gitUserName https://api.github.com/user/repos -d “{“name”:”$repoName"}"

Thanks

Vamshi

Hi,

The below command from the shell script is working fine on my Red Hat Enterprise Linux. But the same does not work from the git bash env. on a Windows system.

The control hangs at this line from the shell script.

What could be the issue?

curl -u $gitUserName https://api.github.com/user/repos -d “{“name”:”$repoName"}"

Thanks

Vamshi

It works now with the following

winpty curl

Thanks

Vamshi