使用git协议时,推送到GitHub会失败

时间:2017-07-13 08:58:20

标签: git github

我正在尝试推送到Github,但我收到以下错误

fatal: remote error
  You can't push to git://github.com/username/repo.git
  Use https://github.com/username/repo.git

我在互联网上看到我必须用http://替换git://但我已将它设置为正确的地址。

这是我的配置:

[remote "origin"]
  url = https://github.com/username/repo.git
  fetch = +refs/heads/*:refs/remotes/origin/*

任何人都知道会导致这个问题的原因是什么?

2 个答案:

答案 0 :(得分:2)

查看git hubs的帮助 https://help.github.com/articles/pushing-to-a-remote#what-can-i-push-to

试试这个

  1. git remote rm origin
  2. git remote add origin
  3. git@github.com:user / repo.git git push origin master

答案 1 :(得分:0)

因此,就我而言,互联网上建议的解决方案都没有奏效。最终对我有用的是完全卸载并重新安装Git。

  • 卸载git
  • 手动删除所有剩余文件
  • 重新启动计算机
  • 再次安装git

重新启动计算机是重要的部分,因为当我重新安装而不重新启动时,它会发生相同的错误。重启似乎可以解决问题。