本文介绍了Git / GitHub无法推送给主人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Git / GitHub的新手,遇到了一个问题。我创建了一个测试项目并将其添加到本地存储库。现在我正在尝试将文件/项目添加到远程存储库。

I am new to Git/GitHub and ran into an issue. I created a test project and added it to the local repository. Now I am trying to add files/project to the remote repository.

这是我所做的(并且工作正常) -

Here's what I did (and this worked) -

git remote add origin git://github.com/my_user_name/my_repo.git

现在,当我尝试使用以下命令将存储库推送到GitHub时,出现以下错误:

Now when I try to push the repository to GitHub, using the following command, I get the following error -

git push origin master

错误 -

fatal: remote error:
You can't push to git://github.com/my_user_name/my_repo.git
Use [email protected]:my_user_name/my_repo.git


推荐答案

GitHub doesn' t支持推送Git协议,这通过使用URL git:// 来表示。如错误消息所示,如果要推送,则应使用SSH URL [email protected]:my_user_name / my_repo.git 或智能HTTP协议通过使用GitHub向您的存储库显示的 https:// URL。

GitHub doesn't support pushing over the Git protocol, which is indicated by your use of the URL beginning git://. As the error message says, if you want to push, you should use either the SSH URL [email protected]:my_user_name/my_repo.git or the "smart HTTP" protocol by using the https:// URL that GitHub shows you for your repository.

令我惊讶的是,有些人显然认为通过这个我暗示了https意味着智能HTTP,而我并不是这样。Git曾经有一个愚蠢的HTTP协议,它不允许在智能引入了GitHub使用的HTTP - 可以用于 http https 。传输协议)

(Update: to my surprise, some people apparently thought that by this I was suggesting that "https" means "smart HTTP", which I wasn't. Git used to have a "dumb HTTP" protocol which didn't allow pushing before the "smart HTTP" that GitHub uses was introduced - either could be used over either http or https. The differences between the transfer protocols used by Git are explained in the link below.)

如果你想改变原始URL,你可以这样做:

If you want to change the URL of origin, you can just do:

git remote set-url origin [email protected]:my_user_name/my_repo.git

git remote set-url origin https://github.com/my_user_name/my_repo.git

更多信息可在

More information is available in 10.6 Git Internals - Transfer Protocols.

这篇关于Git / GitHub无法推送给主人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 09:15