Git SVN: Difference between revisions

From miki
Jump to navigation Jump to search
Line 109: Line 109:
=== More Workflows ===
=== More Workflows ===
* http://ujihisa.blogspot.com/2010/10/git-svn-low-risk-practice.html
* http://ujihisa.blogspot.com/2010/10/git-svn-low-risk-practice.html
* http://stackoverflow.com/questions/190431/is-git-svn-dcommit-after-merging-in-git-dangerous


== Troubleshooting ==
== Troubleshooting ==

Revision as of 18:29, 17 November 2011

This page is dedicated to Subversion integration in Git

References

Configuration

My default .git/config file on Linux:

[user]
    name = ...
    email = ...
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	autocrlf = false
	whitespace = -blank-at-eol, -space-before-tab,-blank-at-eof
[apply]
    ignorewhitespace = change
[svn-remote "svn"]
	url = ...
	fetch = ...
	branches = ...
	tags = ...

My default .git/config file on Cygwin:

[user]
    name = ...
    email = ...
[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	ignorecase = true
	autocrlf = false
	whitespace = -blank-at-eol, -space-before-tab,-blank-at-eof
[apply]
    ignorewhitespace = change
[svn-remote "svn"]
	url = https://www.collabnet.nxp.com/svn/atop
	fetch = trunk:refs/remotes/trunk
	branches = branches/*:refs/remotes/*
	tags = tags/*:refs/remotes/tags/*

Workflow

Get a clone of subversion repository with:

# git: git clone => 
# svn: svn checkout =>
git svn clone https://www.mysvn.org/svn/project -T trunk -b branches -t tags --username='USER'
git svn clone https://www.mysvn.org/svn/project --stdlayout --username='USER'                   # Identical
# Clean / compress git DB if necessary...
git gc

Fetch all changes from SVN repo:

# git: git fetch =>
git svn fetch

Fetch and merge all changes from SVN repo:

# git: git pull =>
# svn: svn update =>
git svn rebase
git svn rebase -l                   # Only rebase against last fetched commit from upstream SVN
In case of conflicts (see [1]):
  • You are on a (no-branch) branch (with git status showing a .dotest file you can ignore)
  • Use the usual git rebase --abort (to bail out), git rebase --continue (solved conflict), git rebase --skip (no-op patch)

Send local changes to SVN repo:

# git: git push =>
git svn dcommit

Annotate changes in a file:

# git: git blame =>
# svn: svn annotate/blame =>
git svn blame fullpath              # Only accept full path! (from project rootdir)
git blame file

Create git .gitignore from svn:

# Typically in project root:
git-svn show-ignore > .gitignore

More Workflows

Troubleshooting

Bugs

  • Byte order not compatible — Recently got the following error on cygwin:
Byte order is not compatible at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_retrieve.al) line 380, at /usr/share/perl/5.10.1/Memoize/Storable.pm line 21
[...] 
Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/lib/git-core/git-svn line 3197
Basically git svn cannot read the content of its cache, and crashes. This can happen after an update of Perl, or when using a copy of a repository that has been created on another machine (typ. with different endianness settings) (see [2] and [3]).
The best fix is to simply delete the git svn cache:
rm -r .git/svn/caches