使用 GitPython 推送到 Git 远程时出现问题:“远程解包失败”和“RPC 失败;HTTP 500”

问题描述 投票:0回答:1

我在尝试使用 GitPython 将更改推送到 Git 远程存储库时遇到问题。我间歇性地收到两个不同的错误,我不确定如何解决它们。

错误1

error: failed to push some refs to 'https://github.com/MyName/gitpython-test'

错误2

  File "c:\Users\User\Documents\doc\pyqt6 app\gitpython-test.py", line 16, in <module>
    origin.push()
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\git\remote.py", line 1126, in push  
    return self._get_push_info(proc, progress, kill_after_timeout=kill_after_timeout)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\git\remote.py", line 917, in _get_push_info
    proc.wait(stderr=stderr_text)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\git\cmd.py", line 657, in wait      
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git push --porcelain -- origin
  stderr: 'error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500
fatal: the remote end hung up unexpectedly'

这是我再次运行程序时遇到的第二个错误。

我很困惑,因为当我直接从 PowerShell 或 CMD 运行类似的命令时,它们运行时没有任何错误。这是我正在使用的 Python 代码:


repo_path = r"C:\\Users\\User\\Documents\\doc\\pyqt6 app\\gitto"
repo = Repo(repo_path)

repo.index.add('.')

repo.index.commit('sad')

origin = repo.remote(name='origin')

origin.push()
python python-3.x git gitpython
1个回答
0
投票

这似乎与Git推送失败HTTP 500curl 22请求的URL返回错误:500内部服务器错误

是同一问题

答案是:

将全局 Git 缓冲区大小增加到最大单个文件大小:

git config --global http.postBuffer 157286400

或者只是为了你的仓库:

cd your_repo
git config http.postBuffer 157286400

或者,如果您从

git fetch
得到相同的错误,它可以使用:

git gc
git fsck
© www.soinside.com 2019 - 2024. All rights reserved.