You can see that error message 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.
The cause of the error is that the current folder is not a git directory.
Check your current folder, and make sure its path is an existing one.
Here, the root cause is using Cygwin, instead of the git bash included with Git For Windows.
The OP yunfei adds in the comments:
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 must include a Git version (2.21 in the Cygwin package list) which was not compatible with other components from Git for Windows: using the git.exe
from Git for Windows is safer.