twid
twid

Reputation: 6686

git force file line ending on commit

We have multi-platform project, which generates binaries for few platforms say mac, windows, linux... Is it possible to force git to change encoding of all files to some particular platform (For example: Linux). So how to change file's line ending every time when users commit or push to remote repository?

Upvotes: 3

Views: 6783

Answers (2)

VonC
VonC

Reputation: 1323403

I would recommend setting core.eol directives in .gitattributes file, rather than relying on a global config like core.autocrlf.

core.eol

Sets the line ending type to use in the working directory for files that have the text property set.
Alternatives are lf, crlf and native, which uses the platform's native line ending.
The default value is native.
See gitattributes(5) for more information on end-of-line conversion.

Upvotes: 2

Atropo
Atropo

Reputation: 12531

I guess you should use a git hook, check this scripts: Git companion scripts by yaegashi.

Upvotes: 4

Related Questions