git - Gitpython git push 推送失败时不会引发异常
问题描述
这似乎是一个已知问题,但我正在寻找解决方法。有人知道一个好的解决方法吗?
https://github.com/gitpython-developers/GitPython/issues/621
(Pdb) test = self.repo.remotes.origin.push(refspec=self.base_branch, progress=None, force=False)
2020-07-18 12:06:55,744|WARNING|guest|Error lines received while fetching: error: failed to push some refs to 'git@github.com:test/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
(Pdb)```
解决方案
如果您的推送成功,您的本地引用origin/branch
应该与branch
.
您可以将其用作解决方法。
这不起作用的唯一情况是:如果您git push
在本地branch
与本地引用在同一点时触发origin/branch
,而branch
在实际远程上更新。
那就是:如果您在没有在分支上提交任何新内容的情况下进行推送。
100% 确定:您可以在推送之前检查是否branch
在origin/branch
,并采取相应措施(不要推送?)。
推荐阅读
- matlab - 罗德里格斯公式不准确?
- cassandra - 如何使用最新版本的 java-driver-core 连接到任何启用 SSL 的 Cassandra 集群
- scala - 异常:java.lang.Double 不能转换为 [D
- azure-ad-b2c - 使用 Azure Pipelines 部署自定义策略,更改字符集编码
- chart.js - 将小时和分钟添加到时间轴的日期对象
- python - 尝试将 Python 与 C 一起使用时,出现错误“未知类型名称 'wctype_t'”
- node.js - EJS - 将数据传递给局部视图并在每个视图/页面中使用它。我怎样才能做到这一点?
- django - 登录后 Django 重定向丢失查询字符串
- r - 如何更改ar文件中每个绘图图形的默认线型
- git - 将部分更改从 master 拉到另一个分支