git 克隆失败,“--stdin 需要 git 存储库”

git clone failure with "--stdin requires a git repository"

我对这个问题很困惑,一直卡在这里,不知道为什么会这样。

我正在使用 git 克隆从 bitbucket 中获取我的 repo,例如 "git clone git@bitbucket.org:mycompny/therepo.git "

但是,我失败了:

fatal: --stdin requires a git repository
fatal: index-pack failed

您可以看到错误消息 introduced in 2016 here:

The index-pack builtin is marked as RUN_SETUP_GENTLY, because it's perfectly fine to index a pack in the filesystem outside of any repository.
However, --stdin mode will write the result to the object database, which does not make sense outside of a repository. Doing so creates a bogus ".git" directory with nothing in it except the newly-created pack and its index.

错误原因是当前文件夹不是git目录。

检查您当前的文件夹,并确保其路径是现有文件夹。

这里的根本原因是使用了 Cygwin,而不是 Git For Windows 中包含的 git bash。

OP yunfei adds :

If I use the git included from my "git bash", by exporting it into my environment in cygwin, I can make it work from cygwin as well.

Just do export PATH="/cygdrive/c/Program Files/Git/cmd":$PATH

Cygwin 必须包含一个 Git 版本(2.21 in the Cygwin package list) which was not compatible with other components from Git for Windows:使用 Git 中的 git.exe 对于 Windows 更安全。