git - 如何在 gitlab 中撤消或恢复 git push?
问题描述
我不小心推了分支而不是主人。
那么有什么方法可以恢复推送,以便我可以带回主代码?我应该执行此命令以从 master 转到另一个分支:
git checkout ProductBranch
但不小心我执行了这个:
git push origin ProductBranch
解决方案
"git push origin ProductBranch"
如果ProductBranch
之前被推送,你可以强制推送它的最后一个状态:
git log ProductBranch
# make sure the history is the correct one, without your new commits
git push --force origin ProductBranch:ProductBranch
如果ProductBranch
以前从未推送过,那么您可以考虑在远程端将其删除:
git push --delete origin ProductBranch
然后,只需切换到 master 并按下它:
git switch master
git push -u origin master
如果您已提交到错误的分支,您可以在 push 之前将这些提交修复回 master。
推荐阅读
- charts - 在 Google Charts 中,如何在 arrayToDataTable 中使用标题行,并且还可以为同一个图表提供选项?
- java - 在Java中从pair中获取值到HashMap
- python - 如何修复 ModuleNotFoundError :没有命名的模块
- sql - 在任何地方我都可以找到 2008 年左右(-4 年,+2 年)NoSQL 与 SQL 数据库的百分比?如果不是,你的估计是什么,为什么?
- google-apps-script - 如何修复以前依赖于 Fusion Tables Advanced Service v1 的谷歌应用程序脚本?
- php - 如何在php中编辑文件?
- kubernetes - Get .pem files in kubernetes with secret certificate
- selenium - 硒随机失效
- python - Changing grid position with a button in python
- amazon-web-services - AWS S3 File Copy - monitor when a file doesn't get moved into S3 Bucket