git Github 推送错误。没有权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8402281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Github push error. Permission denied
提问by chhantyal
I am just trying to create my first repo from Ubuntu 11.10 with this command:
我只是想用这个命令从 Ubuntu 11.10 创建我的第一个 repo:
I was about to finish sudo git push -u origin master
我正要完成 sudo git push -u origin master
Permission denied (publickey). fatal: The remote end hung up unexpectedly
权限被拒绝(公钥)。致命:远端意外挂断
How can this be fixed?
如何解决这个问题?
I tried this too. i.e git push -u origin master. I got this error.
我也试过这个。即 git push -u origin master。我收到了这个错误。
error: could not lock config file .git/config: Permission denied error: could not lock config file .git/config: Permission denied Branch master set up to track remote branch master from origin. error: unable to create directory for .git/refs/remotes/origin/master error: Cannot lock the ref 'refs/remotes/origin/master'. Everything up-to-date
错误:无法锁定配置文件 .git/config:权限被拒绝错误:无法锁定配置文件 .git/config:权限被拒绝 分支主机设置为从源跟踪远程分支主机。错误:无法为 .git/refs/remotes/origin/master 创建目录错误:无法锁定 ref 'refs/remotes/origin/master'。一切都是最新的
采纳答案by Iljaas
Could thisbe of any help?
难道这是任何帮助吗?
Quote:
引用:
Did you forget to add your public key to the github project settings? Also check to make sure your private key is in your .ssh directory.
Goto https://github.com/[usernamehere]/[project name here]/edit and make sure your public key is set.
Read this too: http://help.github.com/mac-key-setup/
您是否忘记将您的公钥添加到 github 项目设置中?还要检查以确保您的私钥在您的 .ssh 目录中。
转到https://github.com/[此处的用户名]/[此处的项目名称]/edit 并确保设置了您的公钥。
回答by Keith
If you're just creating a repo, there's no need to do a git push; git init will create the repo. Also, I would stay away from using sudo when running git. You might also want to go to this site to help you understand git: http://progit.org/book/ch1-3.html
如果您只是创建一个 repo,则无需执行 git push;git init 将创建存储库。另外,我会在运行 git 时避免使用 sudo。您可能还想访问此站点以帮助您了解 git:http: //progit.org/book/ch1-3.html
If you are using github, you might want to read this: http://help.github.com/linux-set-up-git/
如果您使用 github,您可能需要阅读以下内容:http: //help.github.com/linux-set-up-git/
回答by maumercado
Hello it could be because you're trying to git push as root, with sudo, did you set your public key or root key, usually you just supply your key and not the root key, that could be why you're getting such error.
您好,这可能是因为您尝试以 root 身份执行 git push,使用 sudo,您是否设置了公钥或根密钥,通常您只提供密钥而不是根密钥,这可能就是您收到此类错误的原因.
回答by kenorb
If you think it's because of false lock, try removing the lock file:
如果您认为这是因为假锁,请尝试删除锁文件:
Mac or *nix
Mac 或 *nix
rm -v .git/config.lock
Windows
视窗
del .git/config.lock