Git SVN: Difference between revisions

From miki
Jump to navigation Jump to search
Line 110: Line 110:
* 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
* http://stackoverflow.com/questions/190431/is-git-svn-dcommit-after-merging-in-git-dangerous

== Tips ==
;Remove orphaned svn branch
:See [http://stackoverflow.com/questions/5914681/git-svn-bulk-removing-orphaned-remote-branches]


== Troubleshooting ==
== Troubleshooting ==

Revision as of 18:30, 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

Tips

Remove orphaned svn branch
See [2]

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 [3] and [4]).
The best fix is to simply delete the git svn cache:
rm -r .git/svn/caches