How to have Git store CRLF in index

I use git-svn at work and people are constantly complaining that I’m committing LF‘s instead of CRLF‘s. (We’re mostly a Windows shop).

As far as I can tell, when core.autocrlf is true the working copy is CRLF, when false it’s LF, and when input it’s left untouched. I like the autocrlf = true as a concept, but I wish it would default to CRLF in the index since that’s what get’s committed to SVN.

  • git submodule sync command - what is it for?
  • Git core.safecrlf different behavior on files with same line endings
  • Git: http.sslVerify false global but only for specific remote
  • Using git over ssh won't pick up private key
  • setting the work-tree of each bare repo
  • LibGit2Sharp - Best way to stage and commit files
  • Is there a way to set what line ending the index uses?

    I’ve seen core.eol, but this also seems to only set what the working copy uses, not the index.

  • How do I see the commit differences between branches in git?
  • Running MinGW/MSYS tools inside msysgit
  • Git branch select in Jenkins with groovy script
  • git svn and working with private branches?
  • how tell 'git' to 'forget' ALL prior commits?
  • How to make a Git merge operation ignore identical changes made to both branches?
  • 2 Solutions collect form web for “How to have Git store CRLF in index”

    You’ll want to add a file named .gitattributes to the root of your project. This will force everyone to commit same line ending. In you case, as you want to force crlf, you’ll add this line in the .gitattributes:

    * text eol=crlf

    Then, you can also normalize every files in your repo once, and never bother about it again: Trying to fix line-endings with git filter-branch, but having no luck

    You can also refer to github guide on line ending:

    It turns out that git-svn uses the svn:eol-style property from SVN to decide how to store the line endings. If you go into a pure SVN checkout & add svn:eol-style set to native, Git will use CRLF for Windows and LF for Linux/OSX.

    I also have these settings:

    $ git config core.autocrlf false
    $ git config core.safecrlf true

    I don’t have anything in my .gitattributes file.

    Git Baby is a git and github fan, let's start git clone.