Last active
March 24, 2019 20:21
-
-
Save samuelchanx/833c541e9764949ceba8183e45ad6821 to your computer and use it in GitHub Desktop.
Create a repo on gitlab & set remote for current git directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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