关于git push报403的问题

今天在苹果电脑上从GitHub上用IDEA,git到本地一个项目,然后本地修改后,却发现,无法重新push到GitHub上。

git push时遇到了

error: The requested URL returned error: 403 while accessing https: //github.com/username/repo.git/info/refs fatal: HTTP request failed

错误。网上搜索,大部分人都是说修改.git/config文件

[remote “origin”] url = https://github.com/youname/example.git 为:[remote “origin”] url = https://youname@github.com/youname/example.git

再次git push,弹出框输入密码(你在github上注册的用户名和密码),即可提交。

这种做法用到了gtk,所以会弹出输入框来输入密码,我的在这里解决了问题。

其他问题

然而我的centos6上没有安装桌面,所以又报出了GTK错误。

另外一种做法是改成ssh://[email protected]/xxxxx,这种方法需要在github上注册ssh key,否则连不上。

后来发现,这个问题竟然是git的版本落后的问题,centos6的git是1.7.1版本,会遇到这个403错误,但是又不能直接yum更新git。比较彻底的办法是自己重新安装最新版git。

# git clone https://github.com/git/git

# cd git

# make

遇到那个头文件找不到,就安装相应的devel

#make install 

用新的git替换原来的/usr/bin/git 即可解决403问题!

猜你喜欢

转载自blog.csdn.net/qq_21383435/article/details/80569973