通过Bash命令将新项目添加到GitHub?

时间:2014-12-13 07:57:59

标签: git github

是否可以创建一个新项目并将该新项目推送到GitHub而不必打开浏览器,登录Github,并创建一个新项目供您通过GitHub网站推送?

4 个答案:

答案 0 :(得分:2)

技术上你可以。但是您需要使用Github提供的API

还有一个用python编写的包装器,其中包含所有这些包装:查看here

答案 1 :(得分:0)

没有

您必须首先在GitHub中创建存储库。

答案 2 :(得分:0)

你不能。 Github是git的包装器,它不允许你这样做。 原因是在github repos中有github权限,无法通过git管理。

以下是同一个问题:How to create a new repo at Github using git bash?

另一种方法可能是使用github API: https://developer.github.com/v3/repos/#create

答案 3 :(得分:0)

您可以将其添加到您的.bash_profile中:

echo 'mkrepo () { curl -u "<username>" https://api.github.com/user/repos -d "{\"name\":\"$@\"}" ; }' >> ~/.bash_profile

source ~/.bash_profile

然后输入mkrepo <new-repo-name>,它将创建它。 (<username>是您在github上的用户名,<new-repo-name>是您要调用新存储库的名称。