I'm using git-gui for version control and pushing them to remote locations. When I tried to Rescan files for changes, I got this message and I'm not sure what that means. Please help me out here.
Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui. warning: LF will be replaced by CRLF in bin/jarlist.cache. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in gen/com/click4tab/pustakalpha/BuildConfig.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in proguard-project.txt. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in project.properties. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in res/layout/start_test.xml. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in res/menu/start_test.xml. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in src/com/click4tab/pustakalpha/StartTestActivity.java. The file will have its original line endings in your working directory.
The solution is to accept that behaviour. You're on Windows so you should have autocrlf
as true
. It's there so line-endings in Git's internal records are consistent. The warnings are there so you can see if you're about to accidentally corrupt binary files during a commit.
Click Continue. If you want to prevent it happening on those files again, you need to unstage those files, then correct the line-endings and stage them again. Do so by changing the line-endings of the file to CRLF/Windows in your editor, or drop these command line tools into your system32
directory so you can do unix2dos some_file.java
on such files at any command prompt.
I faced similar issues and decided to have a closer look to my configuration.
New Line Characters on Windows / Linux / MAC:
- MAC OS before X: \r = CR (Carriage Return)
- MAC OS X / UNIX: \n = LF (Line Feed)
- Windows: \r\n = CR + LF
Don't panic. Git can handle the conversion between platforms for you.
Git should store the line ending as LF in the repo.
Set it to;
TRUE - If you are on Windows:
git config --global core.autocrlf true
This converts LF endings into CRLF when you check out code.
INPUT - If you are on a MAC/LINUX:
You don't need to convert anything, Git uses LF and your MAC uses LF.
But, you can tell git to convert any CRLF if one pass through:
git config --global core.autocrlf input
False - Not recommened
I don't recommend this, but just for the sake of this explanation:
If you are a windows dev only working on windows machine and you are 100% sure you will never work with people on MAC:
git config --global core.autocrlf false
UPDATE:
As commented below, I didn't mention the .gitattributes where one can default these settings for a project.
If you havetime, here is the doc: http://git-scm.com/docs/gitattributes
This line of code should prevent this warning:
git config core.autocrlf false
If you want a more detailed answer as how and where you enter that line of code, look here: https://stackoverflow.com/questions/3841140/git-how-to-get-rid-of-the-annoying-crlf-message-on-msysgit-windows