我正在合并两个git更改集(或者可能 - 在git rebase'ing,合并更改集的过程中)涉及文件foo,并且有一些合并冲突.该文件看起来像这样:
text appearing in all changesets
<<<<<<< HEAD
text added on the head
=======
something else added on another changeset
>>>>>>> 1babf8ed... commit comment here
more text appearing in all changesets
added text, no conflicts
yet more appearing in all changesets
Run Code Online (Sandbox Code Playgroud)
我的问题:
对于特定文件(foo如上所述)如何显示冲突内容,以便HEAD修订版显示为已删除的文本,另一个更改集(在我的示例中)显示为添加的文本?换句话说,我怎样才能使一些工具处理之间的部分<<<<<和=====作为前缀-的部分>>>>>和=====作为前缀的部分+,或者反过来?
笔记:
冲突不是差异,因为它不是一侧的添加,另一侧的删除。
话虽这么说,像 meld、kdiff3 或 p4merge 这样的工具能够在“并排”视图中显示冲突,以帮助您修复它们。
编辑:
例如:
鉴于通过此脚本创建的情况:
#!/usr/bin/env bash
git init demoRepo
cd demoRepo
git commit --allow-empty -m "Init"
for i in {1..10}; do
echo $i >> myFile.txt
git commit -m "Add ${i} to my file" -- myFile.txt
done
git checkout -b branch2 HEAD~5
for i in A B C D E; do
echo $i >> myFile.txt
git commit -m "Add ${i} to my file" -- myFile.txt
done
git merge master
Run Code Online (Sandbox Code Playgroud)
我们内心有冲突myFile.txt。
设置meld为您mergetool的:
git config --global merge.tool meld
# Use `--local` if you want this setting to be only in current repository
Run Code Online (Sandbox Code Playgroud)
然后用以下方式调用它:
git mergetool
# You may also call it without (pre)defining the tool in config, like:
# git mergetool --tool=meld
Run Code Online (Sandbox Code Playgroud)
Meld 应该知道显示您与“并排”视图冲突。
| 归档时间: |
|
| 查看次数: |
1986 次 |
| 最近记录: |