简体   繁体   中英

Git renormalise not working on an old repo

I've inherited a repo that's been developed on Windows and has always been hosted on Windows. Historically, autocrlf has been disabled, so our main repo will have crlf line endings.

However, we're moving to more of a cross-platform situation, so we want to enable autocrlf .

I've tried running git add --renormalise. as per these answers but when I try and commit it, there are no changes, presumably because they're already CRLF and I'm on Windows, so I can't push it to have it renormalised on the remote.

How would I go about doing this? Do I need to check it out on a Unix machine then do a push?

The git add --renormalize. I mention with Git 2.16+ (Q1 2018) works in collaboration with git config and .gitattributes

Add and commit a .gitattributes with:

*.txt text eol=lf

Then add (with the renormalize option), and commit if needed.

Cloning that repository (with the .gitattributes directives in it) will result in .txt file keeping one consistent EOL (here LF).
Since most Windows IDE/editor know how to preserve LF, that is more convenient for cross-platform development.
And that allows you to keep git config --global core.autocrl false , which I have always recommended .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM