Prashanth Subramanian
Prashanth Subramanian

Reputation: 653

Save changes to Repository level GIT Config

I ran this command

git config --local merge.ours.driver true

It is supposed to make a change in the .git\config file (which is the repository level configuration file). It does make this change.

I can see this change when I run

git config --list

But I do not see this change when I run the same list command from a different user's machine. How can I persist this change across the repository?

It does not show up in 'pending changes', so I cannot check in this change. Is the .git folder being "ignored" ? I couldn't find it in the .gitignore.

Upvotes: 1

Views: 683

Answers (1)

torek
torek

Reputation: 488183

The configuration file .git/config is not itself a version-controlled file.

It can't be, on a fairly fundamental level: it has to exist, and to be full of data, before you start doing any version-controlling. It could refer to (i.e., include, or even be switched with) a version-controlled file after that point, but Git doesn't do that.

What you can do is provide a script that runs whatever configuration items should be run, and commit that script to the repository. Users can then run the script, which can check and correct their configuration as necessary.

(I will also note here that if you are setting up a merge.ours.driver like this, you are probably in for a bit of a shock later when Git uses their version during a merge. Git does not invoke custom drivers unless there are changes on both sides of a merge. If there is a one-sided change, i.e., to their version but not to ours, Git just takes the change.)

Upvotes: 1

Related Questions