git - git 冲突可以像 svn 那样创建其他文件吗
问题描述
我在询问 svn 功能,我想知道它是否存在于 git 中:
当 svn 发生冲突时,它会创建一些有时有用的附加文件:
见https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-conflicts.html
filename.mine - my original file as it existed at the working directory.
filename.BASE_REVISION - The file which is the BASE revision before you updated your working copy. It is the file checked out before you made your latest edits.
filename.NEW_REVISION - This is the file that Subversion client just received from the server. Actually this is the file we want to merge with.
这很有用,因为有时我想将本地更改与 base 进行比较,或者将远程更改与 base 进行比较。或者干脆选择一个文件,并将其设置为冲突的解决方案。
使用 git 并遇到冲突,我看到工作目录中的文件已满,带有 '>>>' '<<<' 标志。
我可以从 git 中获得类似 svn 的行为,拥有这些附加文件吗?我查看了 git 文档,但没有找到合适的东西。
任何想法?
解决方案
如果您想查看冲突的基本版本(如果您问我,这是必须的),可以通过设置merge.conflictStyle
为diff3
. 我看到这个git help merge
:
4. For conflicting paths, the index file records up to three versions: stage 1 stores
the version from the common ancestor, stage 2 from HEAD, and stage 3 from
MERGE_HEAD (you can inspect the stages with git ls-files -u). The working tree
files contain the result of the "merge" program; i.e. 3-way merge results
with familiar conflict markers <<< === >>>.
因此,git ls-files -u
您将获得文件列表,对于冲突,您将获得如下内容:
$ git ls-files -u
100755 ac51efdc3df4f4fd328d1a02ad05331d8e2c9111 1 hello.rb
100755 36c06c8752c78d2aff89571132f3bf7841a7b5c3 2 hello.rb
100755 e85207e04dfdd5eb0a1e9febbc67fd837c44a1cd 3 hello.rb
然后你可以这样做:
git show :1:hello.rb # common ancestor
git show :2:hello.rb # HEAD
git show :3:hello.rb # the other branch
如果您希望将它们作为文件用于分析目的,请使用重定向。
来自https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging的信息
推荐阅读
- c# - 在没有 NewtoNsoft 或非本机依赖项的 C# 中序列化 Json
- azure-logic-apps - 格式化 DateTime 的逻辑应用表达式
- python - 用于输出 JSON 的 Python 脚本的属性值对输出错误
- wikipedia - 地理搜索是否已在所有维基百科上激活?
- apache-nifi - 错误 [main-EventThread] oacframework.imps.EnsembleTracker 收到无效的配置事件
- javascript - 一键跳转到顺序标签
- python - 梯度下降
- c++ - 用 C++ 编写程序,接收 3 个数字并将它们发送到一个函数,然后计算这 3 个数字的平均函数
- database - 如果我在 vertica 中传递一个不存在的资源池怎么办?
- java - Hibernate:从单个表中获取所有记录,无论使用 @DiscriminatorValue 定义的类型如何