git push 报错(403)

今天在GitHub上新建了一个Repository,clone到本地后,发现无法进行push,在网上找了看到有很多解决方法,但是试了很多都没有用,最后在Stack Overflow看到有一种解决方案,正好解决了无法push的问题。

报错信息如下:

1
2
3
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/2ld/l-zz.cn.git/info/refs
fatal: HTTP request failed

解决方案如下:

1.edit .git/config file under your repo directory

2.find url= entry under section [remote "origin"]

3.change it from url = https://github.com/useraccount/repository.git to url=ssh://git@github.com/useraccount/repository.git. that is, change all the texts before @ symbol to ssh://git

4.Save config file and quit. now you could use git push origin master to sync your repo on GitHub

OK,按照以上四步修改完成之后就可以正常push了。


参考:Pushing to Git returning Error Code 403 fatal: HTTP request failed

推荐文章