一半君的总结纸

听话只听一半君

git push error: The requested URL returned error: 403 Forbidden while accessing

这是因为你clone的时候用的是https 这样是只读的

比如

git clone https://github.com/oglops/ffmpeg-static.git
cd ffmpeg-static
git push
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/oglops/ffmpeg-static.git/info/refs

fatal: HTTP request failed

此时你”最好”把repo地址从

https://github.com/user/repo.git

改成

ssh://git@github.com/user/rep.git

要么去.git/config里手改,要么用命令

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

假如你已经设置过了 ssh key, 那就用不着密码了

如果你强迫症的非要用https,那可以

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

这样下次 push的时候,他就会问你密码了,但是的每次手输,如果你“记住”密码,那就会把密码明文保存在config文件里了,所以这样是不推荐的

非要自动记住密码可以这样(最好别,还是用ssh的那个吧)

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

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: