Search code examples
c++linuxgitsmartgit

SmartGit (git) ghost modifications


I currently use smartgit for a personal project.

I have text (.txt) + code (C++) in my repo. Each time I modify my text files and commit them, "ghost" changes automatically appear in my .h and .cpp files.

SmartGit shows modifications but when I check I compare the versions SmartGit says the content of the 2 versions is equal.

I guess this is related to me using both Linux and Windows but I cannot find how to solve the issue. I have looked on the internet but could find no clear answer.


Solution

  • This is due to the line ending being different on Windows (\r\n) and Linux (\n). To fix it, set the core.autocrlf option of git.

    From the Github help page for handling this issue:

    The git config core.autocrlf command is used to change how Git handles line endings. It takes a single argument.

    On Windows, you simply pass true to the configuration. For example:

    git config --global core.autocrlf true
    # Configure Git on Windows to properly handle line endings