GitPython - git add - error - file not recognised

2024-09-26 18:08:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试向提交添加特定文件名时遇到问题。我可以通过--all或u=True等方式使其正常工作。但当我在命令中声明特定名称时,它会给出以下错误:

引发GitCommandError(命令、状态、标准偏差值、标准输出值) git.exc.GitCommandError:Cmd('git')失败,原因是:退出代码(128) 命令行:git add stderr:“致命:路径规范“”与任何文件都不匹配”

但是,当我复制并粘贴cmd行并将其粘贴到gitbash中时,它工作得很好。这是功能问题吗?在

代码如下:

repo.git.checkout('master')  
repo.git.pull 
repo.git.checkout('Test_20191102c') 
repo.git.add(u=False,'Database/Tables/dbo.daletesttable.sql')
repo.git.add('Database/Tables/dbo.daletesttable.sql') 
repo.git.commit('-m', 'test automation git python 001')
repo.git.push('--set', '-upstream', 'origin', 'Test_20191102c')

完整堆栈跟踪:

Repo at C:\sdw successfully loaded.

Traceback (most recent call last):

File "C:/%hiddenpath%/dev2test.py", line 158, in repo.git.add('SDW/Database/Tables/dbo.daletesttable.sql')

File "C:/%hiddenpath%\cmd.py", line 551, in return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)

File "C:/%hiddenpath%\cmd.py", line 1010, in _call_process return self.execute(call, **exec_kwargs)

File "C:/%hiddenpath%\cmd.py", line 821, in execute raise GitCommandError(command, status, stderr_value, stdout_value)

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)

cmdline: git add Database/Tables/dbo.daletesttable.sql

stderr: 'fatal: pathspec 'Database/Tables/dbo.daletesttable.sql' did not match any files'


Tags: inpygitcmdaddtablessqlline

热门问题