Github的代码仓库分为2种类型:
- 用户自己的代码仓库
- 组织的代码仓库
下面就使用Shell脚本创建这2种类型的代码仓库,脚本如下
创建用户自己的代码仓库
#!/bin/bash
USER_NAME="[your username]"
PROJECT_NAME="[project name]"
PROJECT_DESCRIPTION="[project description]"
git init
git add .
git commit -m 'first commit'
curl -u $USER_NAME https://api.github.com/user/repos -d "{\"name\":\"$PROJECT_NAME\", \"description\": \"$PROJECT_DESCRIPTION\"}"
git remote add origin git@github.com:$USER_NAME/"$PROJECT_NAME".git
git push -u origin master
创建组织的代码仓库
#!/bin/bash
USER_NAME="[your username]"
ORGS_NAME="[orgination name]"
PROJECT_NAME="[project name]"
PROJECT_DESCRIPTION="[project description]"
git init
git add .
git commit -m 'first commit'
curl -u $USER_NAME https://api.github.com/orgs/"$ORGS_NAME"/repos -d "{\"name\":\"$PROJECT_NAME\", \"description\": \"$PROJECT_DESCRIPTION\"}"
git remote add origin git@github.com:$ORGS_NAME/"$PROJECT_NAME".git
git push -u origin master