Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git:无法推送GitLab_Git_Gitlab - Fatal编程技术网

git:无法推送GitLab

git:无法推送GitLab,git,gitlab,Git,Gitlab,我在GitLab上创建了一个存储库,并且有一个本地项目 发件人:git-remote-vI获取: origin git@gitlab.com:projects/MyPrj.git (fetch) origin git@gitlab.com:projects/MyPrj.git (push) 当我尝试使用以下命令将其推送到存储库时: git push origin master 我得到这个错误: Permission denied (publickey). fatal: Could not

我在GitLab上创建了一个存储库,并且有一个本地项目

发件人:
git-remote-v
I获取:

origin  git@gitlab.com:projects/MyPrj.git (fetch)
origin  git@gitlab.com:projects/MyPrj.git (push)
当我尝试使用以下命令将其推送到存储库时:

git push origin master
我得到这个错误:

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

Please make sure you have the correct access rights
and the repository exists.
我可以使用web浏览器访问存储库,但不能从命令行的git访问


我做错了什么?

检查与本地克隆回购相关联的远程URL:

cd /path/to/your/repo
git remote -v 
根据其方案(https或ssh),您需要确保正确设置了身份验证

  • https:您需要输入一次凭据,以便将它们缓存在git credential helper中(检查
    git config credential.helper
    返回的内容)
  • ssh:确保您有一个
    /path/to/home/.ssh/id\u rsa(.pub)
    文件(公钥和私钥rsa ssh密钥,公钥内容在远程托管服务上注册)
如果这是SSH(在Linux上),则需要按照“”生成一组新的SSH密钥:

ssh-keygen -P "" -s -t rsa

然后复制GitLab上的
~/.ssh/id\u rsa.pub
内容。

检查与本地克隆repo关联的远程URL:

cd /path/to/your/repo
git remote -v 
根据其方案(https或ssh),您需要确保正确设置了身份验证

  • https:您需要输入一次凭据,以便将它们缓存在git credential helper中(检查
    git config credential.helper
    返回的内容)
  • ssh:确保您有一个
    /path/to/home/.ssh/id\u rsa(.pub)
    文件(公钥和私钥rsa ssh密钥,公钥内容在远程托管服务上注册)
如果这是SSH(在Linux上),则需要按照“”生成一组新的SSH密钥:

ssh-keygen -P "" -s -t rsa

然后将
~/.ssh/id_rsa.pub
内容复制到GitLab上。

如果您使用ssh身份验证,可能值得尝试HTTPS,以检查这是否是问题所在。(我绝不是Git高手,因此除了传递它之外,我无法提供任何内容).For me的可能副本有助于从
git@gitlab.com:…
https://gitlab.com/...
如果您使用的是SSH身份验证,那么可能值得尝试HTTPS,以检查这是否是问题所在。(我绝对不是Git高手,因此除了传递它之外,我无法提供任何内容).For me的可能副本有助于从
git@gitlab.com:…
https://gitlab.com/...