Last active
August 7, 2018 05:58
-
-
Save readingdancer/9504fdd2ef347c4130c7e81087b59c3a to your computer and use it in GitHub Desktop.
Migrate an SVN repo from Beanstalk to Github ( note this does not retain the history, that is more complex and was not required by me backing up some very old repos )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo off | |
echo ! | |
echo ===================================== | |
echo = Script to migrate from SVN to GIT = | |
echo = By Chris Houston = | |
echo = https://www.vizioz.com = | |
echo ===================================== | |
echo ! | |
REM Usage: | |
REM First create a new blank repo on GitHub with the same name as the Beanstalk Repo. | |
REM From a command line that has access to GIT and SVN! | |
REM Run the command: Migrate YourBeanstalkRepoName | |
REM The Beanstalk Repo name is case sensitive, but Git Hub is not. | |
REM You must update: | |
REM YOURBEANSTALKUSERNAME | |
REM YOURBEANSTALKPASSWORD | |
REM YOURACCOUNT | |
REM You will also need to update the folder where you would like the files to be checked out, it will create a new folder for each repo, in the example below, inside the svnMigrations folder | |
REM If you include NOTGIT as the second parameter, it just does the SVN checkout. | |
REM E.g. Migrate YourBeanstalkRepoName NOTGIT | |
REM If you include GITONLY it does the rest of the process ( note, you must be inside the checked out folder if you only run one half of the process and then this half ) | |
REM E.g. Migrate YourBeanstalkRepoName GITONLY | |
REM The following command is useful for finding any files over 100MB which you can manually remove in the middle of the process by using the previous two attributes. | |
REM forfiles /S /M * /C "cmd /c if @fsize GEQ 104857600 echo @path" | |
if "%2" =="GITONLY" goto uploadtogithub | |
if not exist %1 goto createdir | |
echo -- Checking to see if the folder is empty | |
dir /b /a "%1\*" | >nul findstr "^" && (goto foldernotempty) || (goto checkoutsvn) | |
:foldernotempty | |
echo Files already exist, please clear the "%1" directory and re-run the script | |
goto end | |
:createdir | |
echo -- Creating a new %1 directory | |
mkdir %1 | |
:checkoutsvn | |
echo -- Checking out the %1 SVN solution | |
echo on | |
svn checkout "https://YOURACCOUNT.svn.beanstalkapp.com/%1/" "c:\Development\svnMigrations\%1" --username YOURBEANSTALKUSERNAME --password YOURBEANSTALKPASSWORD | |
if "%2" =="NOGIT" goto end | |
:uploadtogithub | |
cd "c:\Development\svnMigrations\%1" | |
echo "%1" >> README.md | |
echo -- Removing any .svn folders so they are not added to GitHub | |
for /d /r . %%d in (.svn) do @if exist "%%d" rd /s /q "%%d" | |
git init | |
git add * | |
git commit -m "Migrating the %1 Repo from Beanstalk" | |
git remote add origin https://github.com/YOURACCOUNT/%1.git | |
git push -u origin master | |
cd .. | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment