git - Git - 撤消合并更改并重做合并
问题描述
我从远程存储库中提取了一些更改:
git 拉
有冲突:
Auto-merging src/app/models/budget-date.ts
CONFLICT (content): Merge conflict in src/app/models/budget-date.ts
Auto-merging src/app/components/timeline/timeline.component.ts
CONFLICT (content): Merge conflict in src/app/components/timeline/timeline.component.ts
Auto-merging src/app/components/timeline-date/timeline-date.component.ts
CONFLICT (content): Merge conflict in src/app/components/timeline-date/timeline-date.component.ts
Auto-merging src/app/components/expenses-log/expenses-log.component.ts
CONFLICT (content): Merge conflict in src/app/components/expenses-log/expenses-log.component.ts
Automatic merge failed; fix conflicts and then commit the result.
我合并了冲突,但我不确定我是否正确合并了冲突,所以我想撤消所有更改并重做合并:
git status
On branch release-0.1
Your branch and 'origin/release-0.1' have diverged,
and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
modified: src/app/components/expenses-log/expenses-log.component.html
modified: src/app/components/expenses-log/expenses-log.component.scss
modified: src/app/services/timeline/timline.service.ts
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: src/app/components/expenses-log/expenses-log.component.ts
both modified: src/app/components/timeline-date/timeline-date.component.ts
both modified: src/app/components/timeline/timeline.component.ts
both modified: src/app/models/budget-date.ts
如何撤消更改并重做合并?
解决方案
您可以通过以下方式恢复该合并:
git revert -m <commit ID>
您也可以使用以下方法
你可以用其他方式git reflog <branch>
来找出你的分支在合并之前的位置,并git reset --hard <commit_id>
恢复旧的修订版(你将回到这个提交)。
然后你可以把它推回去。
它应该很容易。
推荐阅读
- sql - Oracle 数据库中已删除的记录仍由 REST 端点检索
- plugins - Keras 无法加载 uint16 tiff 图像
- python - 如何将多个csv连接到xarray并定义坐标?
- r - 检查日期列表是否介于日期范围列表之间,然后使用 R 编程将关联值添加到新数据帧
- javascript - 如何返回对象中的属性并按顺序排列它们?
- rust - 使用 Sled,我如何序列化和反序列化?
- matplotlib - 使用 Seaborn 的 relplot 代替 Matplotlib 的图
- java - 为什么方法不将布尔值设置为真?
- python - 如何计算数据框中特定单词的实例?
- algorithm - 将 O(logn) 中的两个字符串与一些预处理和假设进行比较