0

So, following on from this (and other) question/answers: git-on-windows-how-do-you-set-up-a-mergetool, which tells us how to setup a diff/merge tool on your local PC (either globally or per project).

For our project (where we are standardising our toolsets and installtions) I want to setup the diff / merge tool just once and roll it out to everyone.

Is there a way to do this? - i.e. when we clone a project it comes with the merge/diff tool config already in it.

I saw inside the .git folder that there is a "config" file - I tried adding:

[diff]
    tool = bcompare

But this did not seem to work when I entered the command git difftool...

Community
  • 1
  • 1
code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • You cannot roll out repository configurations. It’s simply not possible. You could add some setup shell script to the repository that people could execute after cloning the repository but that will not force the repository from using those settings. – poke Nov 14 '16 at 12:15
  • @poke that's a fair strategy if I can't do it in the repo.... add that down as an answer if you like for a +1, and if nothing better comes along I'll mark it. – code_fodder Nov 14 '16 at 12:16

1 Answers1

2

As mentioned in the comments, it is not possible to have repository configurations roll out to everybody who clones the repository. This applies to direct configurations stored in .git/config but also to things like hooks. Whenever you clone a repository, the default repository template is copied from /usr/local/git/share/git-core/templates and complemented with general configurations (e.g. the .git/config and general refs) that are created as part of the cloning process.

Since the configuration is always local to the repository, cloned repositories will also not copy over settings from the origin’s local configuration.

For hooks, the common solution to this problem is to have some setup script, either directly within the repository or as part of some other globally available tooling (e.g. Gerrit’s git-review) that sets up the local configuration when it’s first used.

For your diff/merge tool, you could provide a similar setup script that does this for your team members.

Note though, that tools are often very specific not only to the computer that it’s being used on (e.g. I could have installed my Beyond Compare into a different folder than you), but also very subjective. There may be people who are more comfortable with using tool X instead of the tool Y you configured as a default. So I would recommend to leave this up to the developer. Chances are, if they care, they already set up some tool globally anyway.

poke
  • 369,085
  • 72
  • 557
  • 602
  • Thanks for that, I made a little bat file (sorry... windoze) that configures for beyond-compare, but will also take an optional parameter to specify the path if not default : ) ... thanks for your further comments. – code_fodder Nov 14 '16 at 14:42