Quantcast
Channel: Create a repo in Gitlab using CLI - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by Asclepius for Create a repo in Gitlab using CLI

$
0
0

In comparison with the prior answers by ChillarAnand and eigenfield, although this answer too uses the REST API with curl, it also:

  1. authorizes against GitLab by providing the token in the header, not in the URL
  2. makes curl exit with a nonzero code in case of an error (via -f)
  3. uses the path parameter instead of the name parameter, thereby avoiding the risk of a dissimilar path from being used

First, obtain a token with access to the api scope.

REPO_NAME=foo1GITLAB_TOKEN=xxxxxxxxxxxxxxxxxxxx  # Enter your own.curl -f -X POST \  -H "PRIVATE-TOKEN: ${GITLAB_TOKEN}" -H "Content-Type:application/json" \"https://gitlab.com/api/v4/projects" -d "{\"path\": \"${REPO}\", \"visibility\": \"private\"}"

This answer is relevant only for creating a repository as a user. The request for creating a repository as an admin is different.

As an aside, explicitly creating the repo is optional, since GitLab is known to be capable of creating the repo on first push. (credit: Elan R.)


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>