Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git force file line ending on commit

Tags:

git

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?

like image 881
twid Avatar asked Dec 12 '25 05:12

twid


2 Answers

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

like image 76
Atropo Avatar answered Dec 15 '25 13:12

Atropo


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.

like image 23
VonC Avatar answered Dec 15 '25 12:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!