Search code examples
gitgithubgitattributes

How can we add a project level configuration .gitattributes file to enforce line endings which will be applicable to anyone cloning the repo?


We are working in a project which has code in git and is developed using visual studio. But quite often we have this issue of having the whole file changed because of line endings getting changed automatically. We did consider the option of having line endings setting configured in git on every developer machine but we wanted something more tightly integrated to the repo we are using. I was able to find a solution in the git documentation (https://git-scm.com/docs/gitattributes) but right now I am stuck because I cannot commit this file to the repository since the .git folder is outside the repository. I tried to perform a "git add" for this file but that too did not work.

Any suggestions?


Solution

  • You can place the .gitattributes file at the root of the project work tree. The location of the .git folder has nothing to do with it.