Áxel Costas Pena
Áxel Costas Pena

Reputation: 6305

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?

Upvotes: 3

Views: 218

Answers (1)

VonC
VonC

Reputation: 1330102

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.

Upvotes: 1

Related Questions