简体   繁体   中英

Git - add local config file

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).

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

You should use a .gitattributes file instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM