Git删除远程仓库某次提交记录后的所有提交

1、鼠标右键->git bash here,然后cd切换到代码目录

2、git log查看提交记录,获取commit id

3、git reset commit idcommit id指要保留的最新的提交记录id

4、git push --force,强制push

如果出现remote:GitLab:You are not allowed to force push code to a protected branch on this project.则需要按照下图进行修改

最后点击Unprotect即可。再次执行步骤4,成功。指定提交记录后的所有提交都被删除。
注:删除后,记得恢复Unprotect。

5、git log查看,查看当前最新提交记录id是否为要修改的commit id

相关推荐
像风一样的男人@3 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉4 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞5 小时前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
xlq223226 小时前
7.git
git
Ws_6 小时前
Git + Gerrit 第六课:commit --amend、Patch Set 与 Change-Id
git
AIMath~1 天前
向github中上传文件过大超过50M怎么办
网络·git·github
AIMath~1 天前
如何将一个新的文件夹使用git 工具提交到github新仓库中
git·github
满天星83035771 天前
【Git】原理及使用(二) (版本回退)
linux·git
愿天垂怜1 天前
【C++脚手架】ffmpeg 库的介绍与使用
linux·服务器·开发语言·c++·ide·git·ffmpeg
月夜的风吹雨1 天前
Linux 基础开发工具详解:从 yum 到 gdb 实战指南
linux·git·ubuntu·centos·vim