git rev-parse HEAD 返回非零退出状态 128

Raj*_*sti 2 git gitlab

git commit 遇到这个问题:

fatal: Not a git repository: '.git'
....
 File "C:\Repo\xyz\extern\VerFw\Src\ComponentLineImporter\__init__.py", line 28, in <module>
    from .Version import __version__
  File "C:\Repo\xyz\extern\VerFw\Src\ComponentLineImporter\Version.py", line 22, in <module>
    __version__ = subprocess.check_output('git rev-parse HEAD', cwd=os.path.dirname(os.path.abspath(__file__))).decode().strip()
  File "c:\program files\python36\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "c:\program files\python36\lib\subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'git rev-parse HEAD' returned non-zero exit status 128.
Run Code Online (Sandbox Code Playgroud)

当我唯一的存储库中没有这样的重复文件夹时,为什么会出现此错误ComponentLineImporter

Or *_*r b 5

您需要 CD(更改目录)到您的 git 存储库。您要么不在正确的路径中,要么尚未使用create.

让你的终端位于现有的 git 存储库下。例如,bash您也应该看到您的分支的名称。

例如:

MINGW64 ~/../Source_code/pylint_Forked (master)
$
Run Code Online (Sandbox Code Playgroud)