Reputation: 1832
I've got a repository that stores all of my Vim settings. It uses submodules to pull in plugins with Pathogen (I've looked at other plugin managers, not interested so far).
Due to the way MSYSGit handles line endings when opening Vim for commit messages, I need to have the repository stored with Unix line endings (eol=lf).
I've tried adding a .gitattributes file in the main repo with the content:
* eol=lf
* text=auto
After refreshing the main repository using git rm --cached -r .
and git reset --hard
, the line endings in the main repo are now LF. Running the same commands inside of submodules, however, did not work.
How can configure my git repo so that submodules are checked out with LF line endings?
Upvotes: 14
Views: 1526
Reputation: 11070
I cannot reproduce your scenario, but I suggest you to give a try to git config --global core.autocrlf input
.
With the above instruction you force your system to handle any carriage return in unix format.
Here is a more detailed guide about it.
Upvotes: 1
Reputation: 60615
You can set up a repo template with those settings
git config --global init.templatedir ~/.config/git/init.template
mkdir -p $_/info
printf %s\\n '* eol=lf' '* text=auto' >$_/attributes
then all new clones including the ones git submodule
does for you will have those default attributes.
You can see the factory-default template at the slightly-misnamed /usr/share/git-core/templates
.
I suppose if you wanted you could set init.templatedir
in your vim repo, I haven't checked but seems to me that should work, should make a repo-local template for git submodule
.
Upvotes: 0
Reputation: 34218
Your .gitattributes
file only affects the current working tree according to the documentation:
...Git consults $GIT_DIR/info/attributes file (which has the highest precedence), .gitattributes file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree").
The "work tree" is the directory that represents your repository. If you're in a submodule, its work tree doesn't include the parent repository, and so your file is being ignore.
The solution is probably to add the .gitattributes
file to each subrepo - if you use a global file or configuration, it will be specific to you (as a user) rather than to your code.
Upvotes: 0