Search code examples
gitgithubsublimetext2core.autocrlfphpdesigner

After pushing commit to github, code changes showing wrong


Problem : Here is the real Code Difference & in my commit in github is showing @@ -1,202 +1,251 @@ as this file has been replaced completely. I want to see the difference in code like the below image in github.

enter image description here

System Information : I am editing my code in windows 8.1 with sublime text 2 & in windows 7 with phpdesigner 7

Solutions, I tried before commit :

  • Changed the Line formatting settings in my editor to windows/unix/macOSx
  • In my .gitattribute added * text=auto
  • I have also tried dos2unix & unix2dos commands
  • Strangely, If I edit using vi, it works. But, I am not comfortable using that.

My .gitattribute :

# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs     diff=csharp

# Standard to msysgit
*.doc    diff=astextplain
*.DOC    diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot  diff=astextplain
*.DOT  diff=astextplain
*.pdf  diff=astextplain
*.PDF    diff=astextplain
*.rtf    diff=astextplain
*.RTF    diff=astextplain

Thanks.


Solution

  • The problem is SOLVED.

    What I did wrong

    • I run unix2dos not in recursive mode.
    • I don't know why, but my .gitattribute file was one of the cause

    Solution

    • Run find . -type f -exec unix2dos {} \; This will automatically change all files to crlf/windows format
    • Removed my .gitattributes file

    And TADA, all working as it should be