I have a situation where I am using gitHub to manage changes to a repo I pulled from an open source project that uses svn.
Everything has been all well and good until I realised that in using sed to change stuff, I have changed the svn tracking files. There are just too many to manually fix.
I basically have this problem on a grand scale.
I need these to be intact so I thought I’ll do the following:
- Create a new local working copy of the pristine svn based code.
- Recursively delete all the non “.svn” folders in this tree. I.E., get to a situation where I have the project tree with only “.svn” folders and their contents in it.
- Recursively delete all the “.svn” folders in “gitHub” tree.
- Copy across the “.svn” folder to the “gitHub” tree
Three questions:
- Is this advisable?
- If not, any suggestions on how to recover the svn stuff?
- If on the right track, how do I achieve Step 2? I.E., recursively
delete everything but the “.svn” folders? I have found a lot ofstuff
on Google to do Step 3 but this is the flip of those.
Found that my originally proposed approach has worked just fine.
Steps Taken
directories to hold actual repo and pristine file set:
mkdir /home/build/REPOS/svnrepos && mkdir /home/build/REPOS/svnrepos/repos && mkdir /home/build/REPOS/svnrepos/filescd /home/build/REPOS/svnrepos/repos && svnadmin create project_namecd /home/build/REPOS/svnrepos/files && wget http://site.net/project_name.tar.gz && tar -xzf project_name.tar.gzsvn import /home/build/REPOS/svnrepos/files/project_name file:///home/build/REPOS/svnrepos/repos/project_name -m "Initial import of project_name"temporary svn working folder:
cd /home/build/REPOS/gitrepos && mv GIT_Project GIT_Project_gitmkdir GIT_Project && svn co file:///home/build/REPOS/svnrepos/repos/project_name /home/build/REPOS/gitrepos/GIT_Projectthat is not under a ‘.svn’ directory tree. Leave folder structure
intact:
cd /home/build/REPOS/gitrepos/GIT_Project && find . -type f | grep -v '.svn' | xargs rm -ffolder:
cd /home/build/REPOS/gitrepos/GIT_Project_git && rm -rffind . -type d -name .svn`cd /home/build/REPOS/gitrepos && tar -czf svn.tgz GIT_Projectrm -fr GIT_Projectmv GIT_Project_git GIT_Projectupdated ‘.svn’ folders and contents to the git version folder:
tar -xzkf svn.tgzfiles or folders with a ‘?’ prefix and missing files or folders with
a ‘!’ prefix. save the list to an external file and use find and
replace to change these to “svn add” and “svn delete” respectively.
remember to skip files and folders that should not be added to
svn:
cd GIT_Project && svn statussvn add fileORfolder_1 && svn add fileORfolder_2 ... && svn add fileORfolder_nsvn delete fileORfolder_1 && svn delete fileORfolder_2 ... && svn delete fileORfolder_nsvn commit -m "Realign svn and git"