Home > Blockchain >  Enable git merge ours driver for all users
Enable git merge ours driver for all users

Time:01-03

I want to use merge=ours for a specific file. So I added this to .gitattributes file:

.eslintcache merge=ours

But as stated here, I have to run git config --global merge.ours.driver true. But I want this to be enabled for all contributors in the repo.

Also, I don't understand why the page calls it "a dummy ours merge strategy"! while in this page it seems to be a predefined strategy. Shouldn't it just work without adding this config?

CodePudding user response:

You can't do this because in order to make the option work, it requires configuration, and Git doesn't permit sharing configuration because that would permit arbitrary code execution. For example, if instead of true, you wrote rm -fr ~, then anytime that merge driver was invoked, it would remove the user's home directory.

You can provide a script which users can use to set up their environment, which can set up this configuration, and many projects provide such a script. However, you cannot force a user to run this script or set up this configuration.

If you need this merge strategy to happen automatically, you can perform all merges to the repository with a bot, and then all merges will use the configuration you desire.

  • Related