git提取回购目录“权限被拒绝",但与用户直接链接一起使用 [英] git fetch in repo dir 'Permission denied' but working with direct link with user

查看:100
本文介绍了git提取回购目录“权限被拒绝",但与用户直接链接一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过git访问gerrit上的外部存储库时遇到问题. 当我尝试在克隆的存储库目录中进行 git fetch 时(克隆运行良好),我得到:

I got an issue with accessing the external repository on gerrit through git. When I try to git fetch in cloned repository directory (clone works well) I get:

> git fetch
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

但是当我直接使用存储库ssh地址和用户名执行操作时,我得到:

But when I do it directly with repository ssh address and username I get:

> git fetch ssh://username@ip:port/repo_name
remote: Counting objects: xxxx, done
remote: Finding sources: 100% (xxx/xxx)
etc...

因此直接的 git fetch 似乎运行良好. 我尝试使用以下方法设置不同的用户名:

So the direct git fetch seems to work well. I've tried to set different usernames with:

git config --global user.name "username"

但是没有用-我仍然得到权限被拒绝(公钥). 再次- git clone 正常工作.

But with no use - I still get Permission denied (publickey). Again - git clone works fine.

有什么办法解决这个问题吗?

Any ideas how to fix that?

推荐答案

第一手,检查用于提取的当前URL:

Frist, check the current URL used to fetch:

git remote show origin

然后,如果获取网址不匹配,请使用以下命令对其进行更改:

Then, if the fetch url does not match, change it using the following command:

git remote set-url origin ssh://username@ip:port/repo_name

这篇关于git提取回购目录“权限被拒绝",但与用户直接链接一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆