当前位置:网站首页>The problem that Merge will be lost again after code Revert has been solved
The problem that Merge will be lost again after code Revert has been solved
2022-08-11 02:55:00 【Java Punk】
1. Problem scene
The premise is that my company uses GitLab for code management.
This exception occurred during a regular iterative upgrade of the system not long ago. Due to a problem with the third-party package that the system depends on, the service could not be started. In order not to affect the use of other functions, the master branch wasDo a revert to the last version.
When we solved the problem of dependent packages and re-applied the merge application from dev to master, we found that the code changes were not displayed (Note: If the code is modified, there may also be a "conflict" problem, butEssentially the same), making it impossible to merge branches.That is: the rolled-back code is considered to already exist on the master branch and is not considered a change.
II. Reason analysis
The revert operation is actually just a reverse commit to roll back the merge code, but the commit record still exists.That is to say, the code to be submitted that exists on the dev is actually the past code of the master, which belongs to the state that has been submitted, so it will not display different.
Third, the solution
Option 1: Officially recommended method
The core idea is: revert the commit record that was reverted again.
- First, switch to the master branch and pull a branch revert_tmp based on the master branch.As a copy of master, the role of revert_tmp is to save the commit record of revert;
git checkout mastergit checkout -b revert_tmp
- Secondly, find the version number of the commit record of revert on the master branch, and roll back to the previous version (the version number can be viewed through the "git log" command or from the web page);
git log # Query , format, such as: f2c3b544166eec612ea6814d6cd19aeef46824f8git revert
- Then, switch to the dev branch and merge the revert_tmp branch to the dev branch.
git checkout devgit merge revert_tmpgit push -f
- Finally, resubmit the merge application to master in dev, and you will find that the code before revert is back.
Option 2: reset method
Unlike revert, using -- git reset to move head backward to the commit version before the last merge will discard all merge commit records (revert will not discard it, it is a reverse commit), so merging again will notThere is a problem that records are not displayed or conflicted.
git reset HEAD^ # Roll back everything to the previous versiongit reset HEAD^^ # Roll back everything to the previous version
Note: Use the --hard parameter with caution, it deletes all information up to the fallback point.
HEAD Description:
–hard parameter | Parameter description |
---|---|
HEAD | represents the current version |
HEAD^ | Previous Version |
HEAD^^ | Previous Version |
HEAD^^^ | Last previous version |
And so on... | |
^ can use ~numbers | |
HEAD~0 | represents the current version |
HEAD~1 | Previous Version |
HEAD~2 | Previous Version |
HEAD~3 | Last previous version |
And so on.. |
Summary
- It is recommended to use the official method - revert, which will not delete the version record;
- Article reference: Two methods for Git to restore previous versions reset, revert
边栏推荐
- "Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?
- ES进阶 函数功能语法新特性详解
- 2022制冷与空调设备运行操作考试试题模拟考试平台操作
- 最倒霉与最幸运
- 言简意赅,说说 @Transactional 在项目中的使用
- mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
- A practice arrangement about map GIS (below) GIS practice of Redis
- shell [stdin/stdout/stderr][重定向]
- 添加用户报错useradd: cannot open /etc/passwd
- What does the sanction of the mixer Tornado mean for the DeFi market?
猜你喜欢
leetcode: 358. Reorder strings at K distance intervals
JVM类加载机制
【DB运营管理/开发解决方案】上海道宁为您提供提高工作便利性的集成开发工具——Orange
BUU brushing record
OpenCV founder: Open source must not be completely free!
OpenHarmony啃论文俱乐部-啃论文心得
qtcreator调试webkit
flink The object probably contains or references non serializable fields.
深度学习-第二次
Oops novice template Framework project guide
随机推荐
117. 本地开发好的 SAP UI5 应用部署到 ABAP 服务器时,中文字符变成乱码的原因分析和解决方案
ES进阶 数组功能语法新特性详解
flink The object probably contains or references non serializable fields.
最倒霉与最幸运
基于FPGA状态机的自动售货机功能实现
创业的第125天——随记
超声三维重建总体架构
Ninjutsu_v3_08_2020 - safety penetrating system installation
OpenCV创始人:开源绝不能完全免费!
Ninjutsu_v3_08_2020-安全渗透系统安装
2022制冷与空调设备运行操作考试试题模拟考试平台操作
CSAPP Data Lab
Window function application of sum and count
带你系统学习MySQL索引
SQL 开发的十个高级概念
Detailed explanation of common methods of filtering matrix (array) elements in Matlab
Add user error useradd: cannot open /etc/passwd
Vulnhub靶机:GEMINI INC_ 2
Geogebra 教程之 04 Geogebra 小程序
求和、计数的窗口函数应用