Daniel May
Daniel May

Reputation: 8226

Inconsistent line endings using git-svn with commits from both VCS

I have a remote SVN repository and a local git repository. Using git-svn I have linked git to SVN and am successfully using git svn rebase, git svn dcommit to pull and push to the remote SVN repository.

However, when other people check out my previously-git-edited files with SVN and try to open them in VS2010, they receive a dialog telling them the line endings are inconsistent.

I've read a few things about the core.safecrlf option in git config, but would that fix my issue? I have a number of other people checking in, but we're all running windows - I figured the line endings would be the same?

Would setting core.safecrlf preserve the same type of line ends on checkout and on commit?

Upvotes: 3

Views: 1787

Answers (3)

Patrick O'Hara
Patrick O'Hara

Reputation: 571

Here is a GitHub article that describes your choices for handling end of line characters in Git:

https://help.github.com/articles/dealing-with-line-endings

Essentially Git helps convert EOL on different OS's. SVN has similar functionality. You will need to ensure that they are set in a consistent manner.

Upvotes: 1

Dmitry Pavlenko
Dmitry Pavlenko

Reputation: 8968

Line endings problem is a well-known headache of git-svn. I would recommend to use SmartGit to work with your repository. I respects svn:eol-style value to use correct EOL in Git (translating to it to a corresponding .gitattirbutes value). You may also control svn:eol-style value on pushing to SVN by appropriate changes .gitattirbutes.

If you have an access to the server another approach is possible: just install SubGit into your SVN server. Then a linked Git repository will be created on the server such that every push to it will be automatically translated to SVN and vice versa. It also translates svn:eol-style to .gitattirbutes.

So I would recommend one of these solutions, but not git-svn that is (as I know) painfully slow on Windows.

Upvotes: 1

Nathan Phetteplace
Nathan Phetteplace

Reputation: 993

I have been dealing with this same issue lately. By default, Git on Windows sets core.autocrlf = true. What happens is that your files are checked out from the SVN repo with CRLF line endings, but are committed with unix-style (LF) line endings. When you dcommit those changes, I believe the files are pushed to the SVN server with the unix-style line endings as well. Now when someone checks out those files using SVN, no line ending conversion is performed.

You can set core.autocrlf = false so that no conversion is done. If you are all working in Windows, you shouldn't have any problems. If you are sharing the SVN repo with *nix users, then it is likely that you'll start having inconsistencies. This is the reason for the autocrlf option. The repos should remain consistent, and since Linux doesn't like to play nicely with CRLF, this autocrlf should be set to true.

Upvotes: 4

Related Questions