简体   繁体   中英

Github push error. Permission denied

I am just trying to create my first repo from Ubuntu 11.10 with this command:

I was about to finish 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. ie git push -u origin master. I got this error.

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

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

If you are using github, you might want to read this: http://help.github.com/linux-set-up-git/

Could this be 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/[username here]/[project name here]/edit and make sure your public key is set.

Read this too: http://help.github.com/mac-key-setup/

您好,这可能是因为您尝试以 root 身份执行 git push,使用 sudo,您是否设置了公钥或根密钥,通常您只提供密钥而不是根密钥,这可能就是您收到此类错误的原因.

If you think it's because of false lock, try removing the lock file:

Mac or *nix

rm -v .git/config.lock

Windows

del .git/config.lock

I am going to hazard a guess that you might be using something like etckeeper to keep version control history of /etc changes - which seems to require you to use sudo (at least it makes sense that it would).

I had the same issue as you - I needed to use sudo but could not get it working with the keys registered at github (which was noted as the same key that I was using as my regular sudo user)

What you need is the -E flag - there was no other changes required (assuming you set up for ssh vs https

➜ sudo -E git push -u origin master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 16 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 661 bytes | 661.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 2 local objects.
To github.com:[redacted].git
   5fedc61..3a9b7f6  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
(base) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM