Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a repo in Gitlab using CLI

Tags:

We have a gitlab setup at our office, and we have somewhat around 100-150 project each week to create over there, while Admin wants to keep the control of creating repos and assigning teams to it, it seems quite a bit of task for anyone to create that many repos every week.

Is there a way to create repo on Gitlab using CLI - I won't mind if i have to use ssh for it.

like image 734
Brij Raj Singh - MSFT Avatar asked Oct 25 '13 08:10

Brij Raj Singh - MSFT


People also ask

Can I create a Git repo from command line?

In the command line, navigate to the root directory of your project. Initialize the local directory as a Git repository. Stage and commit all the files in your project. To create a repository for your project on GitHub, use the gh repo create subcommand.

How do I create a repository in GitLab?

After creating your account in GitLab, go to your Projects page and click New project. From the Blank project tab, give the project a name and add a description. If you want it to be a public repository, click the Public option. Make sure the Initialize repository with README option is left unchecked.

Does GitLab have a CLI?

GLab is an open source Gitlab Cli tool written in Go (golang) to help work seamlessly with Gitlab from the command line. Work with issues, merge requests, watch running pipelines directly from your CLI among other features.


1 Answers

gitlab-cli is no longer maintained, the author references the Gitlab module to be used instead - it also includes a CLI tool.

For your specific request - namely creating a project on the command line, use the following command:

gitlab create_project "YOUR_PROJECT_NAME" "{namespace_id: 'YOUR_NUMERIC_GROUP_ID'}"

Be sure to use the option namespace_id and not group_id! If you are not sure what your GROUP_ID is, you can use

gitlab groups | grep YOUR_GROUP_NAME

to find out.

The parameters for each command can be inferred from the API documentation. Any non-scalar valued parameter has to be encoded in an inline YAML syntax (as above).

like image 106
Michael Lihs Avatar answered Nov 11 '22 06:11

Michael Lihs