Git:将合并规则添加到特定文件的配置中 [英] Git: Add merge rule to config for specific file

查看:132
本文介绍了Git:将合并规则添加到特定文件的配置中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用git跟踪我在不同机器上使用Kile编写的大型LaTeX文档。

I am using git to track a large LaTeX document which I write using Kile on different machines.

Kile会写入其 .kilepr 关闭Kile时的配置文件。我经常遇到的问题是,我在 关闭Kile之前就提交了。所以我提交并推送,在另一台机器上工作,当我回来并想拉时,我遇到了合并冲突,因为 .kilepr 文件包含光标位置(其中

Kile writes to its .kilepr config file when closing Kile. The problem I often run into is that I commit before closing Kile. So I commit and push, work on the other machine, and when I come back and want to pull I get a merge conflict because the .kilepr file contains the cursor position (which obviously changed now).

我的问题:有没有一种方法可以将合并规则添加到特定文件的git config中(始终使用-它们)?不能使用 .gitignore ,因为 .kilepr 文件包含重要信息,例如项目中的文件。

My question: Is there a way to add a merge rule to git config for a specific file (always use --theirs)? Using .gitignore is not an option since the .kilepr file contains important information such as files in the project.

推荐答案

模拟合并的所有可能方法-s在 使一个分支像另一个分支一样的git命令

All possible ways to simulate a merge -s theirs are listed in "git command for making one branch like another".

但是对于一个文件,您需要的是一个合并驱动程序,已声明在 .gitattributes 文件中,并带有 keepTheir 脚本,例如:

But for one file, all you need is a merge driver, declared in a .gitattributes file, with a keepTheir script like:

mv -f $3 $2
exit 0

请参阅 > git merge -s他们的,但我知道它不存在作为自定义合并驱动程序的具体示例(包括我自己的版本)。

See ""git merge -s theirs" needed — but I know it doesn't exist" for a concrete example of a custom merge driver (including my own version).

这篇关于Git:将合并规则添加到特定文件的配置中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆