我已经从一个非常活跃的存储库中创建了自己的dev分支。此存储库(Clappr)还包含一个已编译和缩小的文件,该文件使用源代码进行更新。
每当我想用dev重新定位我的master分支时,这个文件就会冲突,因为它不能被自动合并--当然,因为它是一个缩小的JS文件:
$ git checkout dev
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: dummy commit
Using index info to reconstruct a base tree...
M dist/clappr.js
M src/playbacks/hls/hls.js
Falling back to patching base and 3-way merge...
Auto-merging src/playbacks/hls/hls.js
Auto-merging dist/clappr.js
CONFLICT (content): Merge conflict in dist/clappr.js我可以使用--ours来解决这个冲突,但是我必须在master上的每一次提交中都这样做,而这些提交还没有重新建立在基础上。
我知道我可以完全跳过修补程序,但我是否可以自动告诉Git忽略这个clappr.js文件,并且总是使用dev分支中的任何内容?
发布于 2015-07-22 10:24:35
您可以定义自定义合并驱动程序(具体示例在"Git: How to rebase many branches (with the same base commit) at once?“中)。
该合并驱动程序"keepMine“与dist/clappr.js相关联,并在每个分支中的.gitattributes文件中声明合并驱动程序。
见"How do I tell git to always select my local version for conflicted merges on a specific file?“。
echo clappr.js merge=keepMine > dist/.gitattributes
git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"将keepMine.sh放在$PATH中,而不是存储库中:
# I want to keep MY version when there is a conflict
# Nothing to do: %A (the second parameter) already contains my version
# Just indicate the merge has been successfully "resolved" with the exit status
exit 0(关于KeepTheir.sh,请参见"How to stop a merge (yet again…)")
甚至更简单,正如branch14在the comments中所指出的
Linux已经有一个命令可以成功地不执行任何操作,恰当地命名为"
true“。
git config merge.keepMine.driver "true"https://stackoverflow.com/questions/31560274
复制相似问题