我创建了一个新的本地Git存储库:
~$ mkdir projectname
~$ cd projectname
~$ git init
~$ touch file1
~$ git add file1
~$ git commit -m 'first commit'
有没有任何git命令来创建一个新的远程回购,并从这里将我的提交推到GitHub ?我知道打开浏览器去创建一个新的存储库并不是什么大问题,但是如果有一种方法可以从CLI实现这一点,我会很高兴。
我读了大量的文章,但没有一篇提到如何使用git命令从CLI创建远程回购。Tim Lucas的一篇不错的文章“设置一个新的远程git存储库”是我找到的最接近的文章,但是GitHub不提供shell访问。
简单步骤(使用git + hub => GitHub):
Install Hub (GitHub).
OS X: brew install hub
having Go: go get github.com/github/hub
otherwise (having Go as well):
git clone https://github.com/github/hub.git && cd hub && ./script/build
Go to your repo or create empty one: mkdir foo && cd foo && git init.
Run: hub create, it'll ask you about GitHub credentials for the first time.
Usage: hub create [-p] [-d DESCRIPTION] [-h HOMEPAGE] [NAME]
Example: hub create -d Description -h example.com org_name/foo_repo
Hub will prompt for GitHub username & password the first time it needs to access the API and exchange it for an OAuth token, which it saves in ~/.config/hub.
To explicitly name the new repository, pass in NAME,
optionally in ORGANIZATION/NAME form to create under an organization
you're a member of.
With -p, create a private repository, and with
-d and -h set the repository's description and homepage URL, respectively.
To avoid being prompted, use GITHUB_USER and GITHUB_PASSWORD environment variables.
Then commit and push as usual or check hub commit/hub push.
有关更多帮助,请运行:hub help。
参见:在GitHub中使用命令行导入Git存储库。
我用GitHub和BitBucket的REST api写了一个漂亮的脚本,叫做Gitter:
https://github.com/dderiso/gitter
BitBucket都:
gitter -c -r b -l javascript -n node_app
GitHub:
gitter -c -r g -l javascript -n node_app
-c =创建新的repo
-r = repo provider (g = GitHub, b = BitBucket)
-n =命名回购
-l = (optional)设置repo中应用程序的语言