尝试将git HEAD重置为上次提交时无法解析对象

时间:2018-05-23 02:53:19

标签: python git subprocess popen

我有一个在服务器上运行的子进程命令,它将git head重置为最后一次提交。像这样

args = [
    "git",
    "reset",
    "--hard",
    str(self.commit_id),
]

process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.project_directory)
stdout = process.communicate()[0]

if process.returncode != 0:
    error_text = "Error attempting to reset to '{}'\n".format(self.commit_id)
    error_text += "Command: {}\n".format(" ".join(args))
    error_text += "Output: \n"
    error_text += stdout

但这会引发错误:

SystemError: Error attempting to reset to '9eada053b68fbe7209096b214294959f90a87b67'
Command: git reset --hard 9eada053b68fbe7209096b214232329f90a87b67
Output:
fatal: Could not parse object '9eada053b68fbe7209096b214232329f90a87b67'.

9eada053b68fbe7209096b214232329f90a87b67是分支上的最后一次提交。

0 个答案:

没有答案