github push 403 Forbidden

github push 403 Forbidden
root@jun-live:github#git push -u origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/liujun1990/shelltweak.git/info/refs

fatal: HTTP request failed
root@jun-live:.git#cat config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = https://liujun1990@github.com/liujun1990/shelltweak.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

root@jun-live:github#git push -u origin master
Counting objects: 47, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (46/46), done.
Writing objects: 100% (46/46), 22.08 KiB, done.
Total 46 (delta 7), reused 0 (delta 0)
To https://liujun1990@github.com/liujun1990/shelltweak.git
   4882b5b..880f511  master -> master
Branch master set up to track remote branch master from origin.

是权限验证问题,修改.git/config文件追加用户名(和密码)即可。


参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

To definitely be able to login using https protocol, you should first set your authentication credential to the git Remote URI:


git remote set-url origin https://yourusername@github.com/user/repo.git

Then you'll be asked for a password when trying to git push.

In fact, this is on the http authentication format. You could set a password too:


https://youruser:password@github.com/user/repo.git

You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable.


原文地址:https://www.cnblogs.com/lixuebin/p/10814441.html