-1

Can I convert a SVN repo to Git in the following method (asking this as an alternative to svn2git program or git-svn command):

  1. Export the folder/SVN content.
  2. CD into the top level folder and initialize a git repository using git init.
  3. Somehow change the SVN tags/branches to Git tags/branches e.g. How to import svn branches and tags into git-svn?

Would the above be possible or would it not convert correctly?

------------------ Adding files from svn2git ---------------

Rules:

create repository repo
end repository

####comp_refresh_config####

match /(comp_refresh_config/)
  repository repo
  prefix \1
  branch master
end match


####Company####

match /(Company/Source/Projects/[^/]+/)trunk/
  repository repo
  prefix \1
  branch master
end match

match /(Company/Source/Projects/[^/]+/)tags/([^/]+)/
  repository repo
  prefix \1
  substitute branch s/ /_/
  branch refs/tags/\2
end match

match /(Company/Source/Projects/[^/]+/)Trunk/
  repository repo
  prefix \1
  branch master
end match

match /(Company/Source/Projects/[^/]+/)Tags/([^/]+)/
  repository repo
  prefix \1
  substitute branch s/ /_/
  branch refs/tags/\2
end match

match /(Company/Source/Projects/[^/]+/[^/]+/)trunk/
  repository repo
  prefix \1
  branch master
end match

match /(Company/Source/Projects/[^/]+/[^/]+/)tags/([^/]+)/
  repository repo
  prefix \1
  substitute branch s/ /_/
  branch refs/tags/\2
end match

match /(Company/Source/Projects/[^/]+/[^/]+/)Trunk/
  repository repo
  prefix \1
  branch master
end match

match /(Company/Source/Projects/[^/]+/[^/]+/)Tags/([^/]+)/
  repository repo
  prefix \1
  substitute branch s/ /_/
  branch refs/tags/\2
end match

match /(Company/Source/EAR_PACKAGING/[^/]+/)trunk/
  repository repo
  prefix \1
  branch master
end match

match /(Company/Source/EAR_PACKAGING/[^/]+/)tags/([^/]+)/
  repository repo
  prefix \1
  substitute branch s/ /_/
  branch refs/tags/\2
end match

match /(Company/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(Company/)
  repository repo
  prefix \1
  branch master
end match


####Projects####

match /(Projects/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(Projects/)
  repository repo
  prefix \1
  branch master
end match


####certs####

match /(certs/[^/]+/)
  repository repo
  prefix \1
  branch master
end match


####configuration####

match /(configuration/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(configuration/)
  repository repo
  prefix \1
  branch master
end match


####design documents####

match /(design documents/)
  repository repo
  prefix \1
  branch master
end match


####installables####

match /(installables/[^/]+/)
  repository repo
  prefix \1
  branch master
end match


####installables-bundle####

match /(installables-bundle/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(installables-bundle/)
  repository repo
  prefix \1
  branch master
end match


####platform####

match /(platform/[^/]+/)
  repository repo
  prefix \1
  branch master
end match


####reference documents####

match /(reference documents/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(reference documents/)
  repository repo
  prefix \1
  branch master
end match


####referencedocuments####

match /(referencedocuments/[^/]+/)
  repository repo
  prefix \1
  branch master
end match


####releases####

match /(releases/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(releases/)
  repository repo
  prefix \1
  branch master
end match


####scripts####

match /(scripts/[^/]+/)
  repository repo
  prefix \1
  branch master
end match

match /(scripts/)
  repository repo
  prefix \1
  branch master
end match

# Ignore all other directories.
match /
end match

The log file:

progress SVN r1 branch refs/tags/ServiceProblem_epic2_MR3_bce_release_1.0.0 = :1
progress SVN r1 branch refs/tags/sos_ZA_Release_1.0.0_Oct2017 = :2
progress SVN r1 branch refs/tags/Incident_leet_1.0.0_bce_release_1.0.0 = :3
progress SVN r1 branch refs/tags/WON-4FP-XSLT_Special_characterFix_May_2017 = :4
progress SVN r1 branch refs/tags/CPF_HU_Release_1.0_May_2017 = :5
progress SVN r1 branch refs/tags/CbceService-Group1 = :6
progress SVN r1 branch refs/tags/CPF-HU_INC000022903380-LineItemsFix_Release_Oct2017 = :7
progress SVN r1 branch refs/tags/4FP_Italy_Release_Sep_2016 = :8
progress SVN r1 branch refs/tags/CustomerRequest_epic2_drop1.1_bce_release_1.0.0 = :9
progress SVN r1 branch refs/tags/CPF_OctFT_Release = :10
progress SVN r1 branch refs/tags/SalbceidService = :11
progress SVN r1 branch refs/tags/ele_Release_14.0_Feb2018 = :12
progress SVN r1 branch refs/tags/Certs = :13
progress SVN r1 branch refs/tags/CustomerRequestService = :14
progress SVN r1 branch refs/tags/PBI00001047-COPSfieldsFix_March_2017 = :15
progress SVN r1 branch refs/tags/communication-services = :16
progress SVN r1 branch refs/tags/Incident_vcc_2.0.0_bce_release_1.0.0 = :17
progress SVN r1 branch refs/tags/TacticalFix = :18
progress SVN r1 branch refs/tags/LMF-IngramResponseValidation_Fix_Release_1.0_Sept2017 = :19
progress SVN r1 branch refs/tags/CustomerRequest_LMF_1.0.0_bce_release_1.1.0 = :20
progress SVN r1 branch refs/tags/WON_DecimalValidationFix_Release_1.0_Nov2017 = :21
progress SVN r1 branch refs/tags/CustomerRequest_epic2_MR3_bce_release_1.0.0 = :22
progress SVN r1 branch refs/tags/ChangeRequest_LMF_Release_1.0.0 = :23
progress SVN r1 branch refs/tags/Incident_LMF_Release_1.0.0 = :24
progress SVN r1 branch refs/tags/Incident_Sailpoint_1.0.0_bce_release_1.0.0 = :25
progress SVN r1 branch refs/tags/WON_Release_March2017 = :26
progress SVN r1 branch refs/tags/england_Release_1.0.0 = :27
progress SVN r1 branch refs/tags/ele_Release10.0_Dec2017_1.0.0 = :28
progress SVN r1 branch refs/tags/CPF-BR116_Release_1.0_Sep_2017 = :29
progress SVN r1 branch refs/tags/ServiceProblem_LMF_Release_1.0.1 = :30
progress SVN r1 branch refs/tags/4FPShieldUpgradeURLFix_Release_Januray_2018 = :31
progress SVN r1 branch refs/tags/CustomerServiceInventoryItem_ele_MR4.1_MayRelease_1.0.0 = :32
progress SVN r1 branch refs/tags/Incident_smo_epic2_drop1_bce_release_1.0.0 = :33
progress SVN r1 branch refs/tags/connectivity-services = :34
progress SVN r1 branch refs/tags/ServiceFeasibilityService = :35
progress SVN r1 branch refs/tags/ChangeRequest_LMF_Release_1.0.1 = :36
progress SVN r1 branch refs/tags/4FP_FT_Release = :37
progress SVN r1 branch refs/tags/GE_gerco_bce_Release_V1.0_April_2017 = :38
progress SVN r1 branch refs/tags/sos_TLS1.2_Migration_Release_1.0.0_Jan18 = :39
progress SVN r1 branch refs/tags/4FP_partnerWSDL_lightning_release_Feb_2017 = :40
progress SVN r1 branch refs/tags/WON-4FP_DecimalValidationFix_Release_May_2017 = :41
progress SVN r1 branch refs/tags/england_INC000023057409_Fix = :42
progress SVN r1 branch refs/tags/GV = :43
progress SVN r1 branch refs/tags/CustomerRequest_smo_1.0.0_bce_release_1.0.0 = :44
progress SVN r1 branch refs/tags/CustomerRequest_LMF_1.0.0_bce_release_1.0.0 = :45
progress SVN r1 branch refs/tags/Incident_smo_epic2_MR3_bce_release_1.0.0 = :46
progress SVN r1 branch refs/tags/LMF_Release_1.0_June2017 = :47
progress SVN r1 branch refs/tags/ele_Release11.2_Jan2017_1.0.0 = :48
progress SVN r1 branch refs/tags/PBI000010137875-MyOrder_UAT_BugFix_Release_Feb_2017 = :49
progress SVN r1 branch master = :50
progress SVN r1 branch refs/tags/4FP_Spring_Release_2016 = :51
progress SVN r1 branch refs/tags/LMF-INC000022262587_Fix_Release_1.0_Aug2017 = :52
progress SVN r1 branch refs/tags/Incident_smo_1.0.0_bce_release_1.0.0 = :53
progress SVN r1 branch refs/tags/ResourceTest_ele_Release8.2_1.0.0 = :54
progress SVN r1 branch refs/tags/EAR = :55
progress SVN r1 branch refs/tags/4FP_partnerWSDL_lightning_Release_Feb_2017 = :56
progress SVN r1 branch refs/tags/orgacom_Release_2015 = :57
progress SVN r1 branch refs/tags/LMF_EmergencyHotFix_Release_1.0_Jun_2017 = :58
progress SVN r1 branch refs/tags/CbceService-Group2 = :59
progress SVN r1 branch refs/tags/LMF_release = :60
progress SVN r1 branch refs/tags/CPF-Logout_API-Fix-Sep_2017 = :61
progress SVN r1 branch refs/tags/CPF-BREQ144_Release_1.0_Dec_2017 = :62
progress SVN r1 branch refs/tags/LMFRelease1.0.0 = :63
progress SVN r1 branch refs/tags/Incident_smo_epic2_drop1.1_bce_release_1.0.0 = :64
progress SVN r1 branch refs/tags/VCSSalesOrderAdapterService = :65
progress SVN r1 branch refs/tags/SLAMobile_IntialRelease_July2015 = :66
progress SVN r1 branch refs/tags/SalesOrderService = :67
progress SVN r1 branch refs/tags/4FPShield_Release_1.0_Sept_2017 = :68
progress SVN r1 branch refs/tags/OrderEntryService = :69
progress SVN r1 branch refs/tags/LMF_EmergencyHotFix_Release_2.0_Jun_2017 = :70
progress SVN r1 branch refs/tags/SCO_Release_1.0_March_2017 = :71
progress SVN r1 branch refs/tags/WON-SalesOpportunity_TCVCurrencyFix_Release-1.0_Jan2018 = :72
progress SVN r1 branch refs/tags/GE_gerco_bce_Release_V1.2_April_2017 = :73
progress SVN r1 branch refs/tags/SAPP_Mobile_4.0_Release = :74
progress SVN r1 branch refs/tags/CPFr3_3.1_bce_release_1.0.0 = :75
progress SVN r1 branch refs/tags/4FPShield_UpgradeURLFix_Release_Dec_2017 = :76
progress SVN r1 branch refs/tags/ele_Release9.1_Dec2017_1.0.0 = :77
progress SVN r1 branch refs/tags/ChangeRequest_epic2_MR3_bce_release_1.0.0 = :78
progress SVN r1 branch refs/tags/4FP_lightning_Release_Feb_2017 = :79
progress SVN r1 branch refs/tags/4FPShield_Release_1.0_July_2017 = :80
progress SVN r1 branch refs/tags/england_Release_1.0.0_Oct2017 = :81
progress SVN r1 branch refs/tags/Incident_LMF_Release_1.0.1 = :82
progress SVN r1 branch refs/tags/ChangeRequest_epic2_drop1.1_bce_release_1.0.0 = :83
progress SVN r1 branch refs/tags/WON-4FP-DateField_ValidationFix_May_2017 = :84
progress SVN r1 branch refs/tags/CustomerRequest_epic2_drop1_bce_release_1.0.0 = :85
progress SVN r1 branch refs/tags/LMF_Release_1.0_Jun_2017 = :86
progress SVN r1 branch refs/tags/CPF_ES_HU_Fixes_Release_June_2017 = :87
progress SVN r1 branch refs/tags/WON_Release_March_2017 = :88
progress SVN r1 branch refs/tags/ele_CIAM_Fix_Jan2018_release1.0.0 = :89
progress SVN r1 branch refs/tags/Ear = :90
progress SVN r1 branch refs/tags/ServiceProblem_LMF_Release_1.0.0 = :91
progress SVN r1 branch refs/tags/CbceService-Group5 = :92
progress SVN r1 branch refs/tags/CbceService-Group4 = :93
progress SVN r1 branch refs/tags/ele-Catalogue_Release-1.0_July2017 = :94
progress SVN r1 branch refs/tags/PBI_gercoConnectivityFixes_July2017 = :95
progress SVN r1 branch refs/tags/CbceService-Group3 = :96
progress SVN r1 branch refs/tags/CPF_HU_Release1.0_May_2017 = :97
progress SVN r1 branch refs/tags/LMF_Release_1.1_July2017 = :98
progress SVN r1 branch refs/tags/bceRelease_1.0.0 = :99
progress SVN r1 branch refs/tags/CPF-Logout_API-Fix_Sep_2017 = :100
Idris.AH
  • 410
  • 1
  • 10
  • 22
  • Try [SubGit](https://subgit.com). It produces a Git repo that resembles the (way the users think about the) original Subversion repo more accurate than `git-svn` does. – axiac Feb 22 '18 at 10:53
  • @axiac not as good and flexible as the KDE `svn2git` does which he means, not the nirvdrum `svn2git` which would only be a thin wrapper around `git-svn`. ;-) – Vampire Feb 22 '18 at 11:21

1 Answers1

1

If you want the history of the files, there is no way to not use a migration tool like svn2git.
If you want to nuke history ( :-( ), you can just checkout trunk, commit to newly created Git repository, checkout the branches, commit them to Git, checkout the tags, commit them to Git and tag them and so on.
But that is not really a nice migration.
Didn't you get svn2git running properly in the meantime after my help?

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I still have the repo in the bare format. When I try cloning it as below: `git clone ~/Desktop/gitrepo/repo ~/Desktop/test3 Cloning into '.../Desktop/test3'... warning: You appear to have cloned an empty repository. done.` – Idris.AH Feb 22 '18 at 13:44
  • This leaves me with a folder with just .git, but when I check the size , it is still the same size so it must have all the data on it. I get the same result when I git clone the top level folder `~/Desktop/gitrepo` – Idris.AH Feb 22 '18 at 13:51
  • How big is it? What if you do `git log --all --oneline --decorate --graph` in both repos? What if you do `git branch -avv` in both repos? What if you do `git tag -l` in both repos? What if you do `git for-each-ref` in both repos? – Vampire Feb 22 '18 at 14:19
  • I get no output for all of these. Should I re-do the migration? I think the reason the data has come out like this of the svn2git program is because the local svnrepo that I took a dump from was one where I couldn't see the files... I had to run svnserve and inspect the files using localhost. If thats the case, how can I put the svn repo into a form where I can see the files without using svnserve? – Idris.AH Feb 22 '18 at 14:32
  • You just need the svn repository files as they are stored on disk and served by `svnserve` or similar. No special format needed. Can you show your `rules` file, and your `log-repo` file? – Vampire Feb 22 '18 at 14:36
  • It will be too many characters for the comment, is there a way I can share it in a private message? – Idris.AH Feb 22 '18 at 16:24
  • You can either edit your question and add the results or you can start a chatroom with me – Vampire Feb 22 '18 at 16:26
  • Added the files to the question. Thanks for your help up till now – Idris.AH Feb 22 '18 at 17:24
  • This doesn't look correct if that was the full `log-repo` file. It only looked at revision 1 and that's it. Try not ignoring everything with your last match, but explicitly ignore what should be ignored and see about what paths it complains. You can also run with `--stats` to in the end get a list of how often each rule was matched and with `--debug-rules` to see for each path which rule was matched. I guess you miss some recurse rules, so that it actually descends into `/Company/Source/Projects` which currently is probably matched by your ignore-all-others rule. – Vampire Feb 22 '18 at 17:37
  • To only test the rules-matching you can also run with `--dry-run` which is much faster because it does not actually create the repository but is useful for getting the rules setup correctly up-front. – Vampire Feb 22 '18 at 17:38
  • Some of my rules weren't hitting at all so I removed those. The things I don't understand when inspecting the log is when it says `WARN: Branch "refs/tags/Catalogue_Release-1.0_July2017" in repository "repo" doesn't exist at revision 1 -- did you resume from the wrong revision?` and then a little below that it says `355 modifications from SVN //Source/Projects/CustomerService/tags/Catalogue_Release-1.0_July2017/ to repo/refs/tags/Catalogue_Release-1.0_July2017` I know you mentioned that it gives the warning because it doesn't exist, but, what do all the modifications etc mean? – Idris.AH Feb 26 '18 at 10:30
  • `And is there any significance where is says `... exist at revision 1 ...` and then it stops after revision 1? – Idris.AH Feb 26 '18 at 10:35
  • Can the svn2git program work with just a dump of 1 revision? – Idris.AH Mar 07 '18 at 09:42
  • It cannot work with any dump, it always needs the repository files. If you import the dump with `svnadmin`, you can use that. But it doesn't make any sense. If you have only one revision, you can just initiate a new Git repository and commit the files. No need for any migration tool, as there is no history to migrate. – Vampire Mar 07 '18 at 13:50
  • Sorry, I meant the contents of a dump file with one revision and then using svnadmin load to store it in a local repo. But, my question was, is that why is it failing? Lets say I had a dump file with two revisions, would it work then? Because I keep getting the error messages with the "...revision 1". Also, doesn't the program handle the conversion of tags from SVN to Git? – Idris.AH Mar 07 '18 at 14:36
  • It can handle tags just fine, but you need a rule / rules that handle them accordingly, like matching `/tags/([^/]+)/`, writing to `branch refs/tags/\1`, and setting `annotated true`. – Vampire Apr 04 '23 at 09:35