关于git push报403的问题

来源:互联网 发布:意大利航空 知乎 编辑:程序博客网 时间:2024/05/14 03:39

最近在一台centos6上面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://git@github.com/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问题!

0 0
原创粉丝点击