diff -r 997e7523b171 -r 4cda4557f554 git.rst --- a/git.rst Sun Mar 29 17:23:41 2009 +0300 +++ b/git.rst Sun Mar 29 17:59:05 2009 +0300 @@ -116,5 +116,158 @@ * Using git to work with SVN offline. +Prepare SVN and git utilities: + $ sudo apt-get svn git-core git-svn - $ + +Making SVN repo + + $ cd $HOME/tmp + $ svnadmin create svn-repo + $ svn co file://$HOME/tmp/svn-repo svn-devel + $ cd svn-devel + $ mkdir tags trunk branches + $ svn add * +A branches +A tags +A trunk + $ cd trunk/ + $ printf "all:\n echo XXX\n" >Makefile + $ printf "int main() {return 0;}" >main.c + $ svn add * + $ cd .. + $ svn st +A trunk +A trunk/main.c +A trunk/Makefile +A branches +A tags + $ svn ci -m init +Adding branches +Adding tags +Adding trunk +Adding trunk/Makefile +Adding trunk/main.c +Transmitting file data .. + $ svn cp -m v0.0 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/tags/v0.0 + $ svn cp -m v0.1 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/branches/v0.1 + +Moving SVN changset to git repo + + $ cd $HOME/tmp + $ git svn init file://$HOME/tmp/svn git + $ ls -a +. .. .git + $ git svn fetch + A trunk/main.c + A trunk/Makefile +W: +empty_dir: branches +W: +empty_dir: tags +r1 = 52ccd9882979dd53ec198dbac108783ec660410f (git-svn) + A tags/v0.0/main.c + A tags/v0.0/Makefile +r2 = 8ec8a772bb6f37ace56b3649066dc84e481ed427 (git-svn) + M trunk/Makefile +r3 = 2c169ff409ed504dd6a092b1e302beb3fd94871e (git-svn) + A branches/v0.1/main.c + A branches/v0.1/Makefile +r4 = e68d76f4ba6beea4b9059c1884c1f38ce10831a7 (git-svn) + M trunk/Makefile +r5 = cdde63974454b13ac53f2eeb201aa76c49fd875c (git-svn) +Checked out HEAD: + file:///home/sasha/tmp/svn r5 + +Making changes in svn: + + $ cd $HOME/tmp/svn-devel/trunk + $ echo ".PHONY: clean" >>Makefile + $ svn ci -m "Added clean to phony." +Sending trunk/Makefile +Transmitting file data . +Committed revision 6. + +Making committed in git: + + $ cd $HOME/tmp/git-repo/trunk + $ echo ".PHONY: all" >>Makefile + $ echo "int foo(int x) {return x+x;}" >>main.c + $ git status +# On branch master +# Changed but not updated: +# (use "git add ..." to update what will be committed) +# +# modified: Makefile +# modified: main.c +# +no changes added to commit (use "git add" and/or "git commit -a") + $ git commit -a -m "Bug fixed." +Created commit 222d399: Bug fixed. + 2 files changed, 2 insertions(+), 0 deletions(-) + +Getting changes from SVN to git: + + $ git svn rebase + M trunk/Makefile +r6 = 8165e9bfb38e9df09a7313d19606ec227629b670 (git-svn) +First, rewinding head to replay your work on top of it... +Applying Bug fixed. +error: patch failed: trunk/Makefile:6 +error: trunk/Makefile: patch does not apply +Using index info to reconstruct a base tree... +Falling back to patching base and 3-way merge... +Auto-merged trunk/Makefile +CONFLICT (content): Merge conflict in trunk/Makefile +Failed to merge in the changes. +Patch failed at 0001. + +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 + $ git add Makefile + $ git rebase --continue +Applying Bug fixed. + +and return all from git to SVN: + + $ git svn dcommit +Committing to file:///home/sasha/tmp/svn ... + M trunk/Makefile + M trunk/main.c +Committed r7 + M trunk/main.c + M trunk/Makefile +r7 = 68e782c8d06635f2db4dd69b9ca8599f99da22e2 (git-svn) +No changes between current HEAD and refs/remotes/git-svn +Resetting to the latest refs/remotes/git-svn + +See what going to SVN repo: + + $ cd $HOME/tmp/svn-devel/trunk + $ svn diff -r BASE:HEAD +Index: Makefile +=================================================================== +--- Makefile (working copy) ++++ Makefile (revision 7) +@@ -6,4 +6,4 @@ + .o: .c + $(CC) $(CFLAGS) -c -o $@ $< + +-.PHONY: clean ++.PHONY: all clean +Index: main.c +=================================================================== +--- main.c (working copy) ++++ main.c (revision 7) +@@ -2,3 +2,4 @@ + { + return 0; + } ++int foo(int x) {return x+x;} + $ svn up +U Makefile +U main.c +Updated to revision 7. + +