-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-create-repo.sh
executable file
·44 lines (37 loc) · 1.17 KB
/
git-create-repo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#Usage:
#git-create-repo.sh GithubUsername NewReponame
user=$(git config user.name) #github username
github_token="" #github token
repo_name=$1
if [ -z "$user" ]
then
echo "variable \$user is empty, please set variable for github-username in this script first."
exit 1
fi
if [ -z "$github_token" ]
then
echo "variable \$github_token is empty, please set variable in this script first.
How to create a personal access token:
with scopes: write:packages
https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line"
exit 1
#else
# echo "\$github_token is NOT empty"
fi
git init
if [ ! -f "$PWD/README.md" ]; then
echo "# $repo_name" > README.md
fi
#git add .
#git commit -m "First commit"
#
#param="{\"name\":\"$repo_name\"}"
#curl -u $user https://api.github.com/user/repos -d $param
#$pw
#
#curl -H 'Authorization: token '$github_token https://api.github.com/user/repos -d $param
curl -H 'Authorization: token '$github_token https://api.github.com/user/repos -d '{"name": "'$repo_name'", "private": true}'
#
git remote add origin "https://github.com/$user/$repo_name.git"
git push origin master