【问题标题】:Equivalent of git add --patch with two local files等效于 git add --patch 与两个本地文件
【发布时间】:2016-10-03 19:12:57
【问题描述】:

我有两个不同版本的长配置文件(由不同的用户编辑)。我想将它们协调到一个文件中,其中包含两个现有版本中最好的版本。

我知道有专门的工具来处理此类任务(例如 vimdiff),但我习惯了 git add --patch 的工作流程,用于交互式选择要包含在协调文件中的内容。

有没有办法使用git add --patch 工具来合并两个不在 git 中的文件?

【问题讨论】:

  • 没有。使用其他工具,例如 kdiff3。
  • 我同意......只有当文件在 git 中时,使用 git add 才有意义。如果没有,可以使用 kDiff 或 BeyondCompare 等专用工具来做同样的事情。

标签: git merge diff patch


【解决方案1】:

由于您不急于使用 meld 之类的差异工具,因此您可以通过将文件复制到新存储库来使用您熟悉的流程。

mkdir temp
cd temp
git init
cp /path/to/config1 ./config
git add .
git commit -m "first config"
cp /path/to/config2 ./config
git add -p
git commit -m "merged second config"
cp config /path/to/config/

【讨论】:

    猜你喜欢
    • 2013-01-07
    • 2018-09-11
    • 2021-11-11
    • 2018-08-10
    • 1970-01-01
    • 2016-06-23
    • 2013-07-17
    • 2015-04-14
    • 1970-01-01
    相关资源
    最近更新 更多