【问题标题】:Cannot access remote git repository无法访问远程 git 存储库
【发布时间】:2013-09-05 03:06:15
【问题描述】:

我通过 github 网站的“新建按钮”创建了一个 git repo。然后我使用 git bash 设置我的本地仓库并尝试拉取我的远程仓库(它有默认的 README)但得到一个“访问被拒绝错误”,与这个问题中看到的相同: Cannot push to git repository - permission denied

我关注了https://help.github.com/articles/set-up-git#platform-windows,甚至重新打开了一个新的 git bash 会话,但我的远程仓库仍然出现访问错误。我在我的本地仓库中chmod 777,所以这也不是本地问题。

  1. https://github.com/new 创建我的新远程仓库。
  2. 在我的win7电脑上打开git bash,执行如下命令:
    1. git init在项目目录中
    2. git add . 递归添加所有项目文件
    3. git commit -am "commit message"
    4. git remote add origin https://... 产生“致命:远程来源已经存在”。
    5. git pull origin master 产生拒绝访问错误。我首先使用 ssh 尝试了第 4 步,现在我尝试使用 https。

【问题讨论】:

  • 您能否提供更多信息,您究竟运行了哪些命令,以及您得到的确切错误是什么?
  • 你做密码缓存了吗?您提供的 URL 中有一个凭据助手可用...
  • 建议您再仔细查看official documentation
  • git remote -v 说什么?

标签: git windows-7 github


【解决方案1】:

为了获得推送权限,我会在执行第一个 git clone 时使用 ssh 协议/uri(因为这样可以避免一些配置问题)

编辑:为了可能解决您现在遇到的问题,请检查您的 uri,因为它可能就像拼写错误一样简单
使用git config -l检查当前配置
可能会更改为git remote set-url origin git@github.com:path/torepo.git 查看更多here

【讨论】:

  • 我从未做过 git clone,现在也不需要。那从来不是我的命令之一。我使用“新建”按钮通过 github 的站点创建了 git repo。然后我在 git bash(init, add, commit, pull) 中做了所有事情
  • 检查 git remote show ,了解它指向的内容并将远程设置为适用
  • @user1562655 git remote show 只会返回origin 所以没有多大帮助,你是不是还有别的意思?
  • 我安装了 git-credential-winstore 并运行了它,但是在拉取或推送代码时仍然提示我输入用户名和密码,为什么?
  • @HukeLau_DABA https 和 ssh 是不同的身份验证方法,如您链接到 Tip: The credential helper only works when you clone an HTTPS repository URL. If you use the SSH repository URL instead, SSH keys are used for authentication. This guide offers help generating and using an SSH key pair. 的“设置 Git”中所述
【解决方案2】:

试试

git pull origin master

然后

git push origin master

【讨论】:

    【解决方案3】:

    我正在使用“GitHub for Windows”并且有两个 Github 帐户,有时会从一个切换到另一个。

    同样,我得到了这个错误:

    远程:对 .../....git 的权限拒绝 93befbc3eeadfe14e.... 致命:无法访问'https://github.com/....git':请求的 网址返回错误:403

    我解决了“Github for Windows”程序的问题:

    1. 设置(右上角的小齿轮)-->选项
    2. 注销
    3. 选择“添加账户”,其实和“登录”是一样的。然后使用正确的帐户(相应存储库所属的帐户)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-18
      • 2013-04-13
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      • 2010-10-25
      • 2018-12-10
      相关资源
      最近更新 更多