使用Shell创建GitHub仓库
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
==============================================================================本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/p/4722185.html,如需转载请自行联系原作者