Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to force a git add ignoring line ending problems?

I have a giant directory which I need to import into git, and I am suffering the hell of line ending management.

Initially I need to just put everything inside the repo, having no time to deal with line endings. To get that, I added a .gitattributes file with * -text, but that doesn't solve the problem because there are lots of subdirectories containing modules with their own .gitattributes files and text=auto.

Is there any way to get all the files inside the repo with no more struggle?

like image 569
Áxel Costas Pena Avatar asked Sep 15 '25 15:09

Áxel Costas Pena


1 Answers

The gitattributes documentation states:

When deciding what attributes are assigned to a path, 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 further the directory that contains .gitattributes is from the path in question, the lower its precedence).
  • Finally global and system-wide files are considered (they have the lowest precedence).

If you wish to affect only a single repository (i.e., to assign attributes to files that are particular to one user’s workflow for that repository), then attributes should be placed in the $GIT_DIR/info/attributes file.

So try and set your * -text directive in $GIT_DIR/info/attributes, at least for your initial add and commit.

like image 83
VonC Avatar answered Sep 18 '25 04:09

VonC