How to avoid problems with CRLF git-svn and svn like this?

I am using git svn, and today I ran into some problems.

I made git svn clone and worked on my project for a while. A few days later I moved my work to svn remote ( git svn dcommit ). Then I tried to test the project with TortoiseSVN and see if everything was correct. Unfortunately, everything was converted to Unix line endings, and VC6 was unable to open the project.

So, my working version of git was CRLF, but my working version of svn was LF. I assume that git converted it either during git commit or git svn dcommit .

Can I assume that I can avoid all these problems if I set core.autocrlf = false for my working copy of git? Will this git power leave newlines alone? Is there anything else that needs to be done to make git svn easy to use without creating problems for my employees?

(It may also be interesting to mention that I used to use git svn on the same machine without touching the settings, and this was the first time that happened.)

+8
git git-svn newline eol core.autocrlf
source share
1 answer

Subversion has the ability to configure EOL for individual files. And in fact, Git also has this in the form of .gitattributes files (attributes "text" and "eol"). For the general case, core.autocrlf is not enough.

If you set it to false, all files with svn: eol-style = native will have an LF line ending in a working copy of git-svn, which is not expected for windows.

If you set it to true, all line endings will be converted to LF and will be sent to SVN as LF (always).

In fact, svn:eol-style=unset must match the '-text' Git attribute (this means no conversion), svn:eol-style=LF --- to the 'eol = lf' attribute and svn:eol-style=CRLF - - to 'eol = crlf attribute; svn:eol-style=native is system dependent, so it can be controlled with the unversioned eol parameter, so the corresponding Git attribute is'! eol '(this would mean getting the EOL setting from core.eol in .git / config).

Instead of git-svn, you can use any solution that converts svn: eol-style to the corresponding .gitattirbutes values ​​for individual files and vice versa. One solution is the server: you install SubGit in your SVN repository and simply use the clean Git interface that SubGit will create:

 $ subgit install path/to/svn/repository # Git interface with correct .gtattributes repository will appear at path/to/svn/repository/.git # you should setup an access to it 

Then, on the client, you clone it and set core.eol to "crlf" for Windows and "lf" for another OS (the default value is "lf").

 $ git clone <URL> working_tree $ cd working_tree $ git config core.eol crlf #for Windows only 

And after that, Git will behave just like SVN.

Alternatively, on the client side, you can use SmartGit : you can clone the SVN repository with it (not open existing git-svn) --- and then it converts svn: eol-style to .gitattributes. For this case, additional core.eol settings are not required, SmartGit will take care of this.

0
source share

All Articles