Whats the Proper usage of .gitattributes with merge=ours

本小妞迷上赌 提交于 2019-11-29 03:52:36

Easy fix once I knew what I was doing: I missed adding the merge strategy with git config --global merge.ours.driver true in my local environment.

VonC

As mentioned in ".gitattributes & individual merge strategy for a file":

The merge driver is only called in non-trivial cases, i.e. if both master and test have touched setup (and you need to define the merge driver ours first).

You can see an example of concurrent modification (ie modification in both branches) in "How do I tell git to always select my local version for conflicted merges on a specific file?".

So if your merges didn't involve modifications of the same files within cache/ folder in both branches, your merge driver was never called.

But in your case, for files with different settings, I would recommend not using a merge driver, but a content filter driver, as in "Keep settings in branch"

That allows you to keep in version control:

  • template file for the settings in the cache/ folder
  • a script able to take a template file and replace the value placeholders with the right value depending on the branch checked out.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!