【问题标题】:Git push says - The requested URL returned error: 403 but with sudo - worksGit push 说 - 请求的 URL 返回错误:403 但使用 sudo - 有效
【发布时间】:2019-04-11 14:19:03
【问题描述】:

如果我使用命令

git push 

它说致命:无法访问'http://***.git 请求的 URL 返回错误:403 如果我添加 sudo sudo git push 它工作正常。 我应该在哪里添加权限?

我试过了

sudo find /var/www/.git -type d -exec chmod 0777 {} +

还有

sudo find /var/www/.git -type f -exec chmod 0777 {} +

但这只能帮助我从我的用户那里提交

【问题讨论】:

    标签: git ubuntu permissions push sudo


    【解决方案1】:

    所以当我得到新电脑时,我的 ip 改变了(本地)。以前在我们公司是公司代理。 所以我输入了:

    export https_proxy=""
    export http_proxy=""
    

    并添加到您的本地存储库文件夹中

     sudo chown -R YourUserName .git/ 
    

    如果您需要在文件夹中克隆项目,例如来自用户的 var 使用

     sudo find /var/ -type d -exec chmod 0777 {} +
     sudo find /var/ -type f -exec chmod 0777 {} + 
    

    【讨论】:

      【解决方案2】:

      403 是服务器返回的权限错误,而不是您的本地工作站,因此无论多少 chmod 777 都不会改变它。

      检查您的凭证助手:git config credential.helper:当您键入该命令时,您可能已经定义了一个(而不是 rootsudo

      可能是gnome-keyring (now obsolete) or git-credential-libsecret。或存储。

      首先尝试to unset it 进行测试,然后再次推送:它应该查询您的凭据(GitHub 用户名/密码)。检查推送是否成功。

      【讨论】:

      • 是的,我同意你的看法。但它说403错误。看起来像个虫子。当我更改 777 时,它允许我提交。使用 sudo 推送允许。
      • @PashukxCode 是你控制的远程服务器,还是像 github.com 或 gitlab.com 这样的远程 Git repos 托管服务器?
      • 不...我想可能是我从 sudo... 为 http... 或类似的东西制作 rsa 密钥。
      • 当我将我的电脑换成新电脑时会发生这种情况。并保存硬盘。
      • @PashukxCode 是的,重要的是使用 sudo,而仅使用本地 Linux 帐户,在使用 Git 时,才能使用您的关联凭据(如 ~ /.ssh/id_rsa(.pub) 密钥)。
      猜你喜欢
      • 2019-11-05
      • 2022-10-24
      • 2016-06-20
      • 2021-11-14
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 2022-07-31
      • 2022-10-14
      相关资源
      最近更新 更多