Skip to content

Instantly share code, notes, and snippets.

@samuelchanx
Last active March 24, 2019 20:21
Show Gist options
  • Select an option

  • Save samuelchanx/833c541e9764949ceba8183e45ad6821 to your computer and use it in GitHub Desktop.

Select an option

Save samuelchanx/833c541e9764949ceba8183e45ad6821 to your computer and use it in GitHub Desktop.
Create a repo on gitlab & set remote for current git directory
#!/bin/bash
echo "What's the name of the repository?"
read repoName
curl --header "PRIVATE-TOKEN: <YOUR PERSONAL PRIVATE TOKEN from Settings/Access Tokens>" -X POST "https://gitlab.com/api/v4/projects?name=$repoName"
echo "\n"
echo "Done. Do you want to add remote for current directory? (Y) / (N)"
read answer
answerlowercase=$(echo $answer | tr '[:upper:]' '[:lower:]')
repolowercase=$(echo $repoName | tr '[:upper:]' '[:lower:]')
if [ "$answerlowercase" = "y" ]
then
git remote add origin [email protected]:<YOUR REPO USERNAME e.g. samuelchan>/$repolowercase.git
git push -u origin master
fi
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment