我已经使用Git一个月了。我正在将我的Android项目推送到Bitbucket。
有时我会遇到错误,比如:
fatal: Unable to find remote helper for 'https'
但是我使用Git已经有1个月的时间了,实际上它运行得很好。
我搜索了很多次。我使用的是Windows 10 Pro和git-2-12.2.2。
当我使用Windows/cmd或powershell时,会出现错误,但在同一台机器上使用gitbash
时,我不会出现错误。尝试使用gitbash,它可以给你更好的格式。如上所述设置路径和远程url更可能是解决问题根本的可靠解决方案,但我没有必要这样做。我意识到这不是修复错误消息的解决方案,而只是使用我认为已安装在您的计算机上的替代程序。
请尝试确保在CMD会话中重置路径(仅供测试,在该CMD会话中):
set GH=C:\path\to\git2.12.2.2
set PATH=C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
然后再尝试推送。
如果这不起作用,请设置并注册SSH密钥,或者使用SSH URL作为解决方法。
git remote set-url origin git@bitbucket.org:username/repo.git
%GH%\cmd
添加到PATH
中。set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\cmd;%PATH%
另外需要注意的是,我一直在使用安装了Visual Studio
的Git。
这个错误发生的另一种方式是由于打字错误:多了一个:
。
$ git remote add testing file::/rubbish
$ git fetch testing
fatal: Unable to find remote helper for 'file'
$ git remote remove testing
$ git remote add testing file:/rubbish
在使用GitHub Pages部署时,我遇到了类似的问题。我运行npm run deploy
命令时也会出现相同的错误。
我遵循的教程建议我在设置项目时使用HTTPS URL:
$ git remote add origin https://github.com/git-name/repo-name.git
相反,我发现使用SSH URL解决了错误:
$ git remote add origin git@github.com:git-name/repo-name.git
虽然有使用HTTPS与SSH的辩论, 但我看到其他人使用SSH URL解决了类似的问题,于是我也尝试了一下。效果非常好!
要检查和更改远程源,请按照以下命令操作:
$ git remote -v
$ git remote set-url origin git@github.com:git-name/repo-name.git