1

I wish to check in changes that I have made to my local GIT config file and when I tried this command:

git add .git/config --force

It errors out with the following message:

warning: LF will be replaced by CRLF in .git/config.
The file will have its original line endings in your working directory
error: invalid path '.git/config'
error: unable to add '.git/config' to index
fatal: adding files failed

Wondering if this is possible, or if this is considered bad practice. Note: What I am trying to do is check some default diff tools that the entire team needs to use. If this is considered bad practices, how do I go about accomplishing this? (Other settings I might wish to standardize: whitespace, auto conversion of crlf, etc).

Raj Rao
  • 8,872
  • 12
  • 69
  • 83
  • Does this answer your question? [Is it possible to include a file in your .gitconfig](https://stackoverflow.com/questions/1557183/is-it-possible-to-include-a-file-in-your-gitconfig) – LeGEC Jul 07 '20 at 06:37

2 Answers2

2

You cannot add files located under .git/
.git/config also contains local information, such as the list of remote tracking branches, or remote configuration, and it does not make much sense to share these.

Close enough : you can commit a common config file in your repo, and set up each clone with an include directive to include this file :

# relative path are relative to the .git/ directory :
git config include.path ../common_config

Link to docs : includes and conditional includes

LeGEC
  • 46,477
  • 5
  • 57
  • 104
0

You should use a .gitattributes file instead.

Chris Yungmann
  • 1,079
  • 6
  • 14
  • 1
    You cant use .gitattributes for many things. As an example, one cant add difftool settings,etc. – Raj Rao Aug 08 '20 at 21:25