Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can git and subversion play nice together?

Tags:

git

windows

svn

I have recently decided to take the git plunge, and am really enjoying using git, even on Windows.

My current open source project lives on subversion, all devs are familiar with subversion so I would like to keep subversion as the "source of truth" for now.

Nonetheless, I want to use git, so I went ahead and created a copy of the source on github using git svn. All my work is done against the source in github and I push my changes to github. Once every few days I also push my changes to svn and rebase.

The initial import seemed to go ok, but now every time I do a "git svn rebase" I keep on getting conflicts, even on files I have not changed in my get repository. This is causing me much pain.

Eg.

$ git svn rebase
First, rewinding head to replay your work on top of it...
Applying: Added git ignore file
c:/Users/sam/Desktop/MediaBrowserGit/trunk/.git/rebase-apply/patch:12: trailing
whitespace.
*/obj/*
error: .gitignore: already exists in index
Using index info to reconstruct a base tree...
:12: trailing whitespace.
*/obj/*
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Failed to merge in the changes.
Patch failed at 0001 Added git ignore file

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/git-svn: command returned error: 1

My questions:

  1. Is there any way I can tell git to sync itself up with svn using svn as the source, so I can start with a clean slate. (export latest, check in changes and reset the svn refs somewhere)

  2. Are there any tips and tricks to getting this scenario to work consistently?

  3. Should I have the core.safecrlf and core.autocrlf options set to true? It seems I will need a bit of hoop jumping.

Related:

  • http://kerneltrap.org/index.php?q=mailarchive/git/2008/4/16/1450834/thread
  • http://markmail.org/message/vaois4kkr5ggugqs#query:git%20crlf+page:1+mid:i4flex6vmt5tdala+state:results
  • http://code.google.com/p/msysgit/issues/detail?id=271

It seems getting line endings right is a bit of a black art.

(I realize that this question probably needs to be expanded, please comment on the places that need expanding)

like image 590
Sam Saffron Avatar asked Nov 14 '22 15:11

Sam Saffron


1 Answers

Are you getting line-ending conflicts? Git has a few configuration properties you can set that change how it handles the end of line characters. I have the following set:

# this makes git NOT attempt to convert line endings on commit and checkout
core.autocrlf=false

# this makes git check if the conversion done by autocrlf would be reversible
# this is probably not required because I do not have autocrlf turned on
core.safecrlf=true

Note that I am on windows, all my coworkers are on windows and I am interfacing with SVN through git-svn. These settings seem to do the trick for me.

alt text
(source: codinghorror.com)

like image 64
1800 INFORMATION Avatar answered Dec 09 '22 14:12

1800 INFORMATION