How to run svn update in a loop to import commits to git?
I am running a local git repository in parallel to a svn checkout in the same folder. Whenever something new happens on the svn server I run
svn update to download the commits. Then I
git add && git commit the whole set of changes to the git repository.
I want to checkout each commit separately to being able to
git add && git commit the change with the corresponding commit message from svn.
I already found out that I can use
svnversion to retrieve the revision numbers of the working copy and the server.
// svnversion -h usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]] Produce a compact 'version number' for the working copy path WC_PATH. TRAIL_URL is the trailing portion of the URL used to determine if WC_PATH itself is switched (detection of switches within WC_PATH does not rely on TRAIL_URL). The version number is written to standard output. For example: $ svnversion . /repos/svn/trunk 4168 The version number will be a single number if the working copy is single revision, unmodified, not switched and with an URL that matches the TRAIL_URL argument. If the working copy is unusual the version number will be more complex: 4123:4168 mixed revision working copy 4168M modified working copy 4123S switched working copy 4123P partial working copy, from a sparse checkout 4123:4168MS mixed revision, modified, switched working copy ...
I would be happy to discuss ideas with you to solve the task.
A later setup would also include svn externals which is why I cannot checkout the svn repository via git-svn.
3 Solutions collect form web for “How to run svn update in a loop to import commits to git?”
There are two more options you might want to investigate:
SmartGit is Subversion + Git client, that means SmartGit works with local Git repository but you can add svn repository as a remote (similar to git remotes). SmartGit is much more superior than git-svn feature-wise. For more details please refer to SmartGit vs. git-svn comparison.
In particular SmartGit does support both git submodules and svn externals pretty well, so you can even mix them.
SmartGit is proprietary software but it’s free for non-commercial usage.
SubGit is the server-side solution. That means you have to install SubGit and connect it to your Subversion repository that basically includes two steps:
Perform initial translation of SVN repository via SubGit to freshly created Git repository.
Install SubGit specific hooks which are triggered on every
git push, so every change get synchronized between Git and SVN repositories.
For more details you may refer to SubGit documentation.
SubGit is proprietary software. SubGit is free for small teams with up to 10 committers and for academic and open-source projects.
SubGit is also available as an add-on for the Bitbucket Server, to find out more check out here.
I’m SubGit developer and I work in a close contact with SmartGit developers. But these two projects seem very relevant to your particular case. Hope you’ll find my comment helpful.
Well you can try
git svn whose sole purpose is to work with SVN and Git simultaneously.
svn directly. Here is all you need to setup and work with SVN and Git.
I once created a “continous integration” like shell script which was basically an
while true do sleep 42 if svn up | grep '^. ' | egrep '^[ABDUCGE]*' # the first grep drops the "At revision xxx" line # the second grep searches for the update status codes then #do something fi done
But I write this only from memory, maybe there are some other messages which
svn up may produce`.