0

I had a script to create a git repository from command line in GitHub, so my problem is when I try to use my script to create a new repo in GitLab, my script doesn't work !

repo_name=$1

dir_name=`basename $(pwd)`

if [ "$repo_name" = "" ]; then echo "Repo name (hit enter to use '$dir_name')?"  read repo_name fi

if [ "$repo_name" = "" ]; then repo_name=$dir_name fi

username="xxxxxx" if [ "$username" = "" ];  then echo "Could not find username, run 'git config --global github.user <username>'" invalid_credentials=1 fi

token="xxxxxxxx" if [ "$token" = "" ];  then echo "Could not find token, run 'git config --global github.token <token>'"  invalid_credentials=1 fi

echo -n "Creating Github repository '$repo_name' ..."  curl -u "$username:$token" https://api.github.com/user/repos -d '{"name":"'$repo_name'"}' > /dev/null 2>&1 echo " done."

echo -n "Pushing local code to remote ..."  git remote add origin [email protected]:$username/$repo_name.git > /dev/null 2>&1 git push -u origin master > /dev/null 2>&1  echo " done."

so what the equivalent of this

curl -u "$username:$token" https://api.github.com/user/repos -d '{"name":"'$repo_name'"}'

in GitLab?

thank's for your reading!

1
  • Hello! What exactly doesn't work, what is the specific error you've got? Commented Aug 5, 2015 at 16:44

1 Answer 1

3

You may try usingcurl -H "Content-Type:application/json" https://gitlab.com/api/v3/projects?private_token=<your token> -d "{ \"name\": \"<new repo name>\" }" (replace gitlab url with url to your server instance)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank's bro for your solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.