linux - How do I get BASE / REMOTE / LOCAL files without launching a mergetool GUI?
问题描述
I'm not quite sure even how to ask this question... but perhaps:
I am in a conflict state. I want to use null-op
or /bin/bash
as my merge tool.
That is, I want git to create the (REMOTE, LOCAL, BASE, etc) files, and then drop me back to a prompt for manual diff / merging. And then I want to tell git when I'm done.
What is the mergetool I want, and how do I specify it?
Note: This is a related question, but 1) it conflates rebasing (I'm not rebasing), and 2) there is no satisfying answer, e.g. "choose any mergetool and force-quit it." :P
解决方案
git mergetool
是一个 shell 脚本(/bin/sh;/bin/bash 可以运行它,如果你只有 bash 而不是普通的旧 sh)。它:
- 从索引中提取三个文件(
.BASE
= 阶段 1 条目,.LOCAL
= 阶段 2 条目,.REMOTE
= 阶段 3 条目)。第四个文件用作对合并工具的检查——如果您要手动进行合并,则不需要此文件。 - 使用第二个 shell 脚本运行您选择的合并工具。
- 根据工具及其退出状态,询问您是否合并成功,或使用退出状态来决定合并是否成功。如果您说是,它将
git add
在合并文件上运行。 - 删除它在步骤 1 中创建的文件。
对于所有未合并的文件,它会循环执行此操作。
您的工作是修改那个 shell 脚本,以便它提取三个文件并保留它们,即执行(大部分)步骤 1,然后根本不执行其余步骤。只需找到脚本——它就在其中$(git --exec-path)/git-mergetool
——并以另一个名称复制它,例如,git-extract-unmerged
修改它以按照你想要的方式运行,然后运行git extract-unmerged
,你就会得到你想要的那些.BASE
、、.LOCAL
和.REMOTE
文件。
(或者您可以设置merge.conflictStyle
为diff3
并且不打扰上述所有内容,因为工作树文件具有您需要的所有信息。这就是我所做的。)
推荐阅读
- jmeter - Json 提取唯一数据 - Jmeter
- java - How to pass variable from different class to the main class
- javascript - How can I collect data from multiple HTML checkboxes and input that data into a google sheet?
- mysql - How to do audit when using Spring batch as ETL
- r - Create multiple columns in data.table with `:=` without colnames
- javascript - 即使调用了 React 组件方法,expect(...).toHaveBeenCalled() 也会失败
- maple - 如何画出曲线
- python - Asynchronously chaining grpc calls
- angular - Observable subscribe not fired
- spinnaker - How add Bitbucket artifact in Spinnaker?