使用'git remote add origin'和'push'创建新的存储库

3
创建本地仓库并尝试将其推送到 github 时,遇到了问题:
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

我的步骤是标准的 - 这是gitHub帮助建议采用的。

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:MyUser/my-samples.git
git push -u origin master

然后: git push -u origin master

问:如何将新的repo/branch推送到github?

只是想澄清一下:我要从命令行远程创建新库——它在我的github上还不存在。

基本上,我正在尝试执行第11步,网址是http://try.github.io/

顺便说一句,当我尝试使用https://而不是只有git@github.com:... (按照这些步骤)时,我最终出现了403错误

如果我使用"ssh://"将我的密钥添加到github,最终得到Repository not found 错误。但是这个测试sh -T git@github.com成功通过。

所以更新是的,我已经检查了我的连接。


1
当你无法连接到远程主机(在这种情况下是GitHub)时,经常会出现“fatal: The remote end hung up unexpectedly”错误,因此这可能是您的问题。 当您尝试ping GitHub时会发生什么? - user456814
2个回答

3
因此,简单来说,使用git remote add和push命令远程创建仓库是不可能的

因此,当我执行:git remote add origin git@github.com:MyUser/my-samples.git

这并不意味着它将在远程主机上创建新仓库。它意味着它将链接我的origin master分支到远程主机上的一个已经存在的分支

那么,也许有一条命令可以远程创建仓库或项目。

但它是不同的 - 不是使用git remote add和push命令

话虽如此,我认为+ Akash Agrawal 是正确的。回答我的问题只是为了更加清楚明白。

--

这回答了我的问题,如何通过命令行远程创建仓库:是否可以在不打开浏览器的情况下从CLI创建GitHub上的远程仓库?:

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

Or HUB: http://hub.github.com/

# create a repo for a new project
$ git init
$ git add . && git commit -m "It begins."
$ git create -d "My new thing"
→ (creates a new project on GitHub with the name of current directory)
$ git push origin master

1
你需要在 GitHub 上创建一个仓库才能将更改推送到其中。裸仓库不会自动初始化。否则,拼写错误可能会导致意外创建新的仓库。

这就是问题所在 - 我希望能够在不必通过浏览器访问GitHub的情况下创建新的存储库。 - ses

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接