Skip to content
A script for merging from SVN to GIT and usage tips for Continuous Integration with OSX Server and XCode
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


What's this?

This is a bash script which saves you the trouble of merging to git from SVN. This script was written to be used either in the OSX terminal or with OSX Server and XCode for Continuous Integration purposes.

It's purpose

Long story short, OSX Server doesn't play well with pure SVN repos, and if neither SVN over ssh or merging to git are feasible options, then you're just have to do it the hard way.

There are some tools out there, which help you keep SVN and Git in sync. But if you really want to control the process and make a one way only communication, from SVN to Git, then you'll have to come up with your own script to do that. Or just use mine, at least as a reference point.

Use it within you CI process or GIT merge

These script can also be used as a pre/post script action for various xcode phases(build, test, archive) of a scheme which an XCode bot runs on. A bit confusing, right? In other words, to be used in the process of automating builds within the CI process, with the help of OSX Server, XCode and bots.

# This script is used to pull data from the SVN and push it to git




# remove any old data from the local git
echo "Removing old data from ${GIT_CHECKOUT_DIR}"

# get the latest revision from the local git
echo "Cloning ${LOCAL_GIT_URL} into ${GIT_CHECKOUT_DIR}"

# if we’re not always cloning the git repo, for getting the latest data we should
# git reset --hard
# git clean -fd
# git pull

# remove any old data from SVN
echo "Removing old data from ${SVN_CHECKOUT_DIR}"

# get the latest revision from the SVN repo
echo "Cloning ${SVN_URL} into ${SVN_CHECKOUT_DIR}"
git svn clone ${SVN_URL} ${SVN_CHECKOUT_DIR}

# if we’re not always cloning the svn, for getting the latest data we should
# git svn rebase
# git svn fetch

# copy the latest SVN data into the git clone directory 
echo "Copying new data into ${GIT_CHECKOUT_DIR}"

# copying this way will prevent the copy of hidden .git directories or .gitignore. 
# so every checkout preserves it's reference to it's own origin.
cp -rf * ../${GIT_CHECKOUT_DIR}

# check for any changes and commit
echo "Pulling from the local git into ${GIT_CHECKOUT_DIR}"
git pull
git status

# It might be wise to check for the “index.lock” and remove it
rm -f ${GIT_CHECKOUT_DIR}/.git/index.lock

echo "Committing and pushing changes to the local git repo’s master"
# look also for newly added files
git add -A

# commit changes to the master branch
git commit -a -m "Updated from SVN"
git push ${LOCAL_GIT_URL} master

#remove temp data
echo "Removing temporary data"
cd ..
You can’t perform that action at this time.