簡體   English   中英

為什么 Git 有時會給我這樣的錯誤:“fatal: Unable to find remote helper for 'https'”

[英]Why Git sometimes give me error like “fatal: Unable to find remote helper for 'https'”

我使用 git 1 個月了。 我正在將我的 Android 項目推送到 Bitbucket。

有時我會收到類似的錯誤

fatal: Unable to find remote helper for 'https'

但正如我所說,我使用 git 1 個月實際上它運行良好。
我搜索了很多次。 我使用的是 Windows 10 專業版和 git-2-12.2.2

當我使用 windows/cmd 或 powershell 時,我收到該錯誤,但在同一台機器上,當我使用gitbash我沒有收到該錯誤。 嘗試使用 gitbash,無論如何都會為您提供更好的格式。 如上所述設置路徑和遠程 url 更有可能是問題根源的可靠解決方案,但我不必這樣做。 我意識到這不是修復錯誤消息的解決方案,而只是使用我認為已安裝在您的機器上的替代程序。

[[如果您使用嵌入在 Android Studio 中的 git] 問題是與 Android Studio 一起運行的默認 git.exe 程序不支持 https。 要解決此問題,您應該安裝 git 並替換默認的。 執行以下步驟:

  1. 從以下位置安裝最新的 git: https : //git-scm.com/download/win
  2. 在 Android Studio 中:文件 > 設置 > 版本控制 > Git 在“執行 Git 的路徑”中,指向 git.exe 的位置(例如 C:\\Program Files\\Git\\bin\\git.exe)。 然后運行測試。

如果一切正常,將會有一個彈出消息顯示 git 已成功執行和 Git 版本。

就這樣。 再次嘗試拉取代碼!

嘗試並確保在 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

對我來說,@VonC 方法幾乎有效,我還需要將%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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM