问题
tl;dr: Running git status --ignored
in the root of my project never finishes. git status
works fine.
I started seeing the symptoms of this issue from my IDE - PhpStorm (though this issue would apply to all IntelliJ IDEs). No git-related operations (commit, push, fetch) work, all of them would hang endlessly. Looking at the running processes, turns out there was a git
process taking 100% CPU.
Killing the git processes made the IDE run smoothly again for a couple of minutes. Seems like it periodically spawns the process to sync up changes. Some experimenting later, turns out this is not an issue of PhpStorm, but of git
. git status --ignored
never finishes even when executed from the command line.
回答1:
In my case, the culprit was a deep directory structure in the project path. It must have been generated by something in our tool stack I didn't notice, because it was over 100 directories deep, with no actual files present there.
cp
refused to copy this directory, saying name too long (not copied)
. I'm guessing git
somehow trips up on directories like this.
Deleting the deeply nested dir hierarchy fixed the issue for me and git status --ignored
works as expected now.
Edit: this was confirmed to be a bug in git
. Exerpt from the mailing list:
There is no such directory depth limit, but the runtime of 'git status --ignored' grows quickly with the depth of the untracked directory. Running this shell loop produces the numbers below:
10: 0.01 11: 0.03 12: 0.05 13: 0.11 14: 0.23 15: 0.47 16: 0.97 17: 1.97 18: 3.88 19: 7.85 20: 16.29 21: 32.92 22: 76.24
Beautifully quadratic, isn't it? :)
Unless I messed up my numbers, with a depth of 120 directories it would take over 6*10^23 years to complete... so yeah, it does qualify as indefinitely.
来源:https://stackoverflow.com/questions/59928800/git-status-ignored-hangs-indefinitely