2

I am puzzling on this issue and stuck here with no clue why it happens.

I am using git clone to get my repo from bitbucket like "git clone git@bitbucket.org:mycompny/therepo.git "

But, I am failed with something like:

fatal: --stdin requires a git repository
fatal: index-pack failed
yunfei
  • 526
  • 2
  • 6
  • 20

1 Answers1

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks VonC, I think the case in your link is different than mine. I am doing clone under a clean directory, there is no .git . – yunfei Jan 10 '20 at 06:35
  • @yunfei the link is not about a "different case": it is about when and why that particular error message was introduced. – VonC Jan 10 '20 at 06:37
  • @yunfei What git version are you using, on which OS (and OS version)? – VonC Jan 10 '20 at 06:38
  • I am using git 2.21.0 on cygwin, I am using windows10. Thanks! – yunfei Jan 10 '20 at 06:41
  • @yunfei cygwin? Don't use cygwin. A git bash maybe, but try it frst in a regular CMD, with a simplified PATH: https://stackoverflow.com/a/54624681/6309. And use for testing the 2.24.1 – VonC Jan 10 '20 at 06:43
  • I can do the clone from my windows based ubuntu virtual machine. – yunfei Jan 10 '20 at 06:43
  • @yunfei Exactly: 2.24 in a regular CMD with a simplified PATH should give you the same successful clone. – VonC Jan 10 '20 at 06:44
  • I have been getting used to cygwin for many years, then I may change my bad habit:( – yunfei Jan 10 '20 at 06:45
  • @yunfei git bash included with Git for Windows will allow you to keep those same habits. Even a regular CMD will give you all the same Linux commands, it you are using the simplified PATH I recommended. – VonC Jan 10 '20 at 06:46
  • @yunfei let me (and others) know if it works with a simplified PATH (from a CMD, or a CMD where you typed 'bash', if you want to do so from a cygwin-like shell) – VonC Jan 10 '20 at 06:54
  • Hi VonC, I thought I confirmed it works from windows power shell, also works from git bash. But my question was trying to understand how can my failure happen. Even I was using the cygwin git, and a different version, the error does not make sense to me. – yunfei Jan 10 '20 at 07:41
  • 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 – yunfei Jan 10 '20 at 07:44
  • @yunfei Well done. I have included your comment in the answer for more visibility. – VonC Jan 10 '20 at 08:32