没有不值得去解决的问题,也没有不值得去学习的技术!

基于 TortoiseGit 重置版本至最新的一次有效提交

决定将可能存在冲突文件的几次提交给删除,重置版本至最新的一次有效提交
1、在某位开发人员的提交中,存在了已经冲突的文件,且未手动解决冲突,就强制提交了代码,如图1
在某位开发人员的提交中,存在了已经冲突的文件,且未手动解决冲突,就强制提交了代码
图1
2、决定将可能存在冲突文件的几次提交给删除,重置版本至最新的一次有效提交,如图2
决定将可能存在冲突文件的几次提交给删除,重置版本至最新的一次有效提交
图2
3、选择硬重置,所有之后的 commit 的修改直接丢弃,如图3
选择硬重置,所有之后的 commit 的修改直接丢弃
图3
4、重置成功,如图4
重置成功
图4


git.exe reset --hard 086fc817cc3d149adf8ebc0489d75b3958ea111f --

HEAD is now at 086fc81 Merge remote-tracking branch 'origin/develop' into develop

成功 (593 ms @ 2019/03/18 18:21:37)


5、本地文件已经还原至最新的一次有效提交,冲突提示已经消失,如图5
本地文件已经还原至最新的一次有效提交,冲突提示已经消失
图5
6、推送时,提示需要先拉取代码,但是此时是不应该拉取代码的,否则,又会将存在冲突的文件给拉取下来,如图6
推送时,提示需要先拉取代码,但是此时是不应该拉取代码的,否则,又会将存在冲突的文件给拉取下来
图6


git.exe push --progress "origin" develop

To https://gitlab.chinamcloud.com/php/pcs-api.git
! [rejected]        develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://gitlab.chinamcloud.com/php/pcs-api.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


git 未能顺利结束 (退出码 1) (2657 ms @ 2019/03/18 18:30:15)



7、强制将内容推送到远程服务器,如图7
强制将内容推送到远程服务器
图7


git.exe push --force-with-lease --progress "origin" develop

Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote:   https://gitlab.chinamcloud.com/php/pcs-api/merge_requests/new?merge_request%5Bsource_branch%5D=develop
remote:
To https://gitlab.chinamcloud.com/php/pcs-api.git
+ b04e465...086fc81 develop -> develop (forced update)

成功 (4156 ms @ 2019/03/18 18:51:42)





8、在 Gitlab 上查看 Git 服务器上的提交日志,发现最新的提交ID已经还原至:086fc817cc3d149adf8ebc0489d75b3958ea111f,如图8
在 Gitlab 上查看 Git 服务器上的提交日志,发现最新的提交ID已经还原至:086fc817cc3d149adf8ebc0489d75b3958ea111f
图8
 

需要长期技术维护或远程问题排查?

我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。

如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:

  • ✅ PHP / Laravel / Yii2 老项目无人维护
  • ✅ Go / Gin 后端接口需要排查或优化
  • ✅ WordPress 网站访问慢、报错或插件冲突
  • ✅ Nginx / MySQL / Redis / Linux 服务器异常
  • ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
  • ✅ 需要长期远程技术支持或兼职维护

更多介绍请查看:关于我 & 合作

微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理