Home > Enterprise >  How to make git detect errors in config?
How to make git detect errors in config?

Time:05-25

On one of my machines I made a typo when configuring git, which resulted in this entry in the .gitconfig file:

[credentials]
    helper = cache

Can you spot the error? I spelled credentials instead of credential. Of course, git accepted this without any error/warning/biting remark.

Is there a way to ask git to validate the config file and flag any entry that:

  • is ignored (e.g. alias pull = pull --no-ff)
  • does not match any available configuration variable (like the above credentials vs. credential mismatch)

CodePudding user response:

The short answer is no. The reason for this is that the configuration file format is deliberately free-form; any entries that Git doesn't use are ignored, so that other programs can create such entries. For all Git knows, there's some non-Git program that uses credentials.helper for something.

(It would make some sense for Git to detect things that it does know about but skips, such as aliases for built-in commands.)

  • Related