我有一个在服务器上运行的子进程命令,它将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是分支上的最后一次提交。