github api 在 git bash 中不起作用,但在 cmd 中它可以

github api does not work in git bash, but in cmd it does

你好,当我在 Git Bash 中测试 git 集线器 api 时一切正常,直到我使用此命令:

curl -i -u myuser https://api.github.com/users/myuser

但是当我在 windows cmd 中执行它时,它工作得很好,它立即要求我输入密码,我已经尝试卸载和安装 git 但它不起作用。

在这里我展示发生了什么 https://www.loom.com/share/8aabb02719424117ad0f70ba40ce5234

我刚刚在 git bash 会话中对其进行了测试:

vonc@vclp MINGW64 ~/git/git (master)
$ curl -i -u VonC https://api.github.com/users/VonC
Enter host password for user 'VonC':
...
{
  "login": "VonC",
  ...
}

确实有效。

但是我的 %PATH%(在键入 bash 之前)是来自 CMD:

C:\Users\vonc\git\git>where curl
C:\Program Files\Git\mingw64\bin\curl.exe
C:\Windows\System32\curl.exe

所以我使用 Git 中的 curl 作为 Windows, 之前使用 Windows。

根据您的视频和“cURL won't prompt me for password using GitHub API”,尝试添加 winpty:

winpty curl -u <me> https://api.github.com/users/<me>