【问题标题】:github api does not work in git bash, but in cmd it doesgithub api 在 git bash 中不起作用,但在 cmd 中起作用
【发布时间】:2021-10-12 20:30:54
【问题描述】:

您好,当我在 Git Bash 中测试 github api 时,一切正常,直到我使用此命令:

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

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

我在这里展示正在发生的事情 https://www.loom.com/share/8aabb02719424117ad0f70ba40ce5234

【问题讨论】:

  • 您能描述一下当事情不起作用时实际发生的情况吗?您收到错误消息吗?
  • 它没有给我任何错误,就好像它正在加载,但在 cmd 中它是瞬时的

标签: git github cmd git-bash


【解决方案1】:

我刚刚在 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

所以我使用 Windows 版 Git 中的 curl之前是 Windows 版。

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

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

【讨论】:

  • 非常感谢您的回答,事实是我是git和这个世界的新手,我不明白,我不知道我是否解释清楚我的情况,所以附上一个简短的问题中的视频
  • @IvanRaulSanchezDiaz 我明白了。我已经相应地编辑了答案,并提供了可能的解决方案。
猜你喜欢
  • 2014-08-05
  • 1970-01-01
  • 1970-01-01
  • 2020-11-26
  • 2014-05-17
  • 1970-01-01
  • 2020-04-27
  • 2021-10-13
  • 2022-10-24
相关资源
最近更新 更多