【问题标题】:Git Push Error - Could not resolve host nameGit 推送错误 - 无法解析主机名
【发布时间】:2014-11-13 21:59:56
【问题描述】:
nshastri@N-SHASTRI ~/datasciencecoursera (master)
$ git push origin master

ssh:无法解析主机名 https:没有与名称关联的地址

致命:无法从远程存储库读取。

请确保您拥有正确的访问权限 并且存储库存在。

【问题讨论】:

  • 那么,您的实际问题是什么?
  • maaster 将是master????

标签: git push


【解决方案1】:

简单输入:

git remote -v

并仔细检查与origin 关联的网址是否为您的upstream repo

一旦你有了正确的 url,用另一个 git remote command 更新你的远程源:

git remote set-url origin /the/right/url

在你的情况下,网址是错误的:

https:/github.com/nkshastri/datasciencecoursera.git
# instead of:
https://github.com/nkshastri/datasciencecoursera.git
     ^^^^

简单输入:

git remote set-url origin https://nkshastri@github.com/nkshastri/datasciencecoursera

然后再试一次:

git push -u origin master

(使用master,而不是maaster

【讨论】:

  • 感谢您的帮助,我试过了,但仍然没有成功。我发布了一个屏幕截图以供参考。
  • @NarendraKumarShastri 你用的是什么操作系统和git版本?
  • 我的操作系统是windows 7 Git bash版本是1.9.4-preview20140815
  • @NarendraKumarShastri git remote -v 的输出是什么(没有截图,只有文字)
  • 我无法发布屏幕截图,因此输出为:nshastri@N-SHASTRI ~/datasciencecoursera (master) $ git remote -v origin https://github.com/nkshastri/da​​tasciencecoursera.git (获取)来源 https://github.com/nkshastri/da​​tasciencecoursera.git(推送)
【解决方案2】:

有时这可能是由网络问题引起的。尝试重新启动您的 wifi,或者,如果存储库位于 VPN 之后,请确保您在 VPN 上。

【讨论】:

  • 在重新启动服务器后发生。在我的 Mac 上禁用/启用 wifi 暂时解决了它:)
【解决方案3】:

您可能正在尝试连接 FALSE NAME DIR 您的存储库名称应与本地环境中的文件夹名称相同。

git 仓库:gitRepo 文件夹名称:gitRepo 现在你可以推送了

首先将您的新存储库 CLONE 到另一个文件夹,然后您可以将您的代码复制到这个新文件夹,然后将其名称更改为正确的 git 存储库名称,这也是一个好习惯。

【讨论】:

    【解决方案4】:

    对于我在~/.git-credentials 我有两个凭据已被存储。 所以我保留了一个我想互动的东西,现在推拉工作正常。

    有关 git-credentials 的更多信息,请关注link

    【讨论】:

      【解决方案5】:

      此解决方案仅适用于小型项目...

      为了解决这个问题...我创建了一个新目录,其中包含与旧目录中同名的文件。

      只需将旧文件中的代码复制粘贴到新目录的相应文件中...

      然后执行通常的命令链...

      git remote add URL_OF_YOUR_REPO
      git branch -M main
      git status
      git add .
      git commit -m "Problem Solved!"
      git push -u origin main
      

      在此之后没有遇到任何错误。对小型仓库很有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-30
        • 1970-01-01
        • 1970-01-01
        • 2014-04-20
        • 2011-05-20
        • 1970-01-01
        • 2017-03-26
        • 2012-12-17
        相关资源
        最近更新 更多