User Tools

Site Tools


software:svnsyncgit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
software:svnsyncgit [2018/11/17 23:08]
solar [Fetch the data]
software:svnsyncgit [2021/05/14 22:23] (current)
solar
Line 183: Line 183:
 git commit git commit
 git svn dcommit git svn dcommit
 +</code>
 +
 +===== Re-Building =====
 +
 +If, for some reason, you lose that Git setup created above, you need to re-build it:
 +
 +<code>
 +git clone git@github.com:/DevSolar/pdclib
 +cd pdclib
 +git svn init -s svn://rootdirectory.ddns.net/pdclib --prefix=svn/
 +</code>
 +
 +Now you need to re-build the ''authors.txt'' file (as above). Then comes the tricky part: If your SVN repository has moved //ahead// of your Git repository (i.e. you sync Git -> SVN), you need to re-build the setup //with the SVN revision you left off with//. You can find the revision number of each synced SVN commit in ''git log'', in the ''git-svn-id'':
 +
 +<code>
 +commit 5950958ff57391789d9a164a56cd1ed87dedaa12 (HEAD -> master, origin/master, origin/HEAD)
 +Merge: 02e56d5 ec5835f
 +Author: Martin Baute <solar@rootdirectory.de>
 +Date:   Tue Feb 2 10:59:34 2021 +0100
 +
 +    Merge branch 'trunksvn'
 +
 +commit ec5835f129d8f9629d334657d4c31b40d6190724
 +Author: solar <solar@bcf39385-58cc-4174-9fcf-14f50f90dd47>
 +Date:   Mon Feb 1 21:15:12 2021 +0000
 +
 +    git-svn-id: https://srv183.svn-repos.de/dev34/pdclib/trunk@992 bcf39385-58cc-4174-9fcf-14f50f90dd47
 +                                                               ^^^
 +</code>
 +
 +A bit easier is to have the computer extract the number for you:
 +
 +<code>
 +REVISION=$(git log | grep git-svn-id | head -n1 | sed -e "s/.*@//" -e "s/ .*//")
 +</code>
 +
 +Now fetch everything from your SVN repository //up to that revision//:
 +
 +<code>
 +git svn fetch -r0:$REVISION --authors-file=authors.txt
 +</code>
 +
 +Set up the sync branch, and link it to the SVN remote:
 +
 +<code>
 +git branch --no-track trunksvn
 +git checkout trunksvn
 +git reset --hard remotes/svn/trunk
 +</code>
 +
 +Now rebase the branch //to what you already fetched//. The ''--local'' option keeps ''git svn'' from connecting to the repository (which would fetch the revisions SVN is ahead, which we do not want at this point).
 +
 +<code>
 +git svn rebase --local
 +</code>
 +
 +Now we merge the sync branch to our master. This is basically a no-op, but it sets the merge point from which we will proceed.
 +
 +<code>
 +git checkout master
 +git merge trunksvn --allow-unrelated-histories
 +</code>
 +
 +Now we are set up again, and can sync the SVN revisions we left out previously by the "normal" procedure. 
 +
 +<code>
 +git checkout trunksvn
 +git svn rebase
 +git checkout master
 +git merge trunksvn
 +git push origin master
 </code> </code>
  
software/svnsyncgit.1542492523.txt.gz ยท Last modified: 2018/11/17 23:08 by solar