错误信息如下:

$ git push origin master
error: The requested URL returned error: while accessing https://github.com/
shines77/gzmalloc.git/info/refs?service=git-receive-pack
fatal: HTTP request failed

相关解决办法可参考如下两篇网文:

(1). github初试-403错误

http://www.cnblogs.com/hanxiangduo/archive/2012/09/03/github.html

(2). Pushing to Git returning Error Code 403 fatal: HTTP request failed

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

(1), (2)文中提到了解决的办法是把项目的URL路径由https改为ssh:

git remote set-url origin ssh://git@github.com/shines77/gzmalloc.git

改了以后, 在Git Bash命令行模式下执行git push origin master正常了, 但是使用TortoiseGit推送依然报错:

Disconnected: No supported authentication methods available (server sent: publickey)

原因是TortoiseGit不能直接使用git的ssh的私钥, 所以要用PuttyGen导入git产生的ssh私钥, 产生TortoiseGit能够识别的putty私钥和公钥.

这样的方法虽然通用, 但是比较麻烦, 后来我看到(2)文中有人提到由

https://shines77@github.com/shines77/gzmalloc.git
改成
ssh://git@github.com/shines77/gzmalloc.git

就成功了, 其实提问者问题里使用的就是 https://shines77@github.com/shines77/gzmalloc.git 这个的格式, 没太注意看.

看到这样的格式, 我就在TortoiseGit试了一下, 竟然可以push了.

GitHub现在网站上提供的https路径格式是:

https://github.com/shines77/gzmalloc.git

只要把https路径改为:

https://你的github用户名@github.com/shines77/gzmalloc.git

https://shines77@github.com/shines77/gzmalloc.git

即可, 具体原因不明.

这样用Git Bash和TortoiseGit都可以pull和push了, 简单快捷.

这里说一下产生这个错误的原因, 是因为我有两个github帐号, 我想用这两个的帐号维护各自帐号下的代码仓库.

本来只使用一个github帐号维护其帐号下的代码仓库时, 使用默认的https路径是没有问题的, 但使用第二个github帐号维护第二个帐号下的代码仓库时,

就出现了上述的403错误, 就算我把全局设置.gitconfig里和TortoiseGit中该仓库下的email和name修改为第二个帐号, 也一样不行, 使用上面的方法就OK了.

我猜出现这种情况的原因, 大概是由于有两个github帐号, 所以必须指定具体是哪个帐号才能正常访问.

附:

PuttyGen下载地址

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

最新文章

  1. MySQL的存储引擎
  2. Lable得到自定义高度!
  3. 【转】获取手机的ipv4地址
  4. elasticsearch 搜索不支持单词的部分进行匹配
  5. CSS3+HTML5特效9 - 简单的时钟
  6. sublime C++ build system配置体验
  7. Raft论文学习笔记
  8. How to set spring boot active profiles with maven profiles
  9. WebApi 之HelpPage帮助页
  10. Winows + VSCode + Debug PHP
  11. python dic字典使用
  12. 国内写的比较好的markdown教程
  13. Android 开发 倒计时功能 转载
  14. EasyPR源码剖析(8):字符分割
  15. ctf学习(web题二)
  16. 编码原则 之 Persistence Ignorance
  17. .ashx文件与.ashx.cs
  18. NE555
  19. php性能优化(一)压力測试工具篇
  20. 点击input文字会自动消失

热门文章

  1. 【bzoj3110】[Zjoi2013]K大数查询 整体二分+树状数组区间修改
  2. 聊聊flink的Async I/O
  3. windows提权基础大全
  4. _MSC_VER
  5. php中foreach使用引用的陷阱
  6. 实例讲解启动mysql server失败的解决方法
  7. 779D. String Game 二分 水
  8. java绝对路径和相对路径的理解
  9. Log-structured File Systems
  10. Lua只读表