Created
December 18, 2014 12:55
-
-
Save asimzeeshan/ea6583ae0a697d2ef4ea to your computer and use it in GitHub Desktop.
Migrating SVN (with no branches) to GIT on Debian based systems (all steps)
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
| # ============================================================ | |
| # Author: Asim Zeeshan | |
| # Web: http://asim.pk | |
| # ============================================================ | |
| # Ensure you have SVN, GIT & GIT-SVN packages installed | |
| # apt-get install subversion git git-svn | |
| # | |
| # NOTE: DO NOT TRY WITH "-no-metadata" SWITCH BECAUSE I RAN INTO MANY ISSUES WITH IT | |
| # Lets Begin! | |
| # ============================================================ | |
| # STEP 1: Get list of SVN Users | |
| # ============================================================ | |
| svn log -q http://svn.example.com/svn/MyRepo | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq > ~/authors | |
| # NOTE: If it asks you for user/pass, do the following | |
| # svn co http://svn.example.com/svn/MyRepo | |
| # provide you user/pass and when asked SAVE YOUR CREDENTIALS. | |
| # Then run the commands above without issues | |
| # ============================================================ | |
| # STEP 2: Start the conversion | |
| # ============================================================ | |
| mkdir /home/tmp/ | |
| cd /home/tmp/ | |
| git svn init http://svn.example.com/svn/MyRepo | |
| # edit the file created in step1 and ensure its in the following format, do this for every username in that file | |
| # nano ~/authors | |
| # john_doe = John Doe <john.doe@example.com> | |
| git config svn.authorsfile ~/authors | |
| git svn fetch | |
| git svn show-ignore >> .git/info/exclude | |
| git svn rebase | |
| # ============================================================ | |
| # STEP 3: Push everything over to a new & clean Git repo | |
| # ============================================================ | |
| git config user.name "John Doe" | |
| git config user.email "john.doe@example.com" | |
| git remote add gitlab git@github.com:asimzeeshan/MyRepo.git | |
| git push -u gitlab master | |
| # ============================================================ | |
| # STEP 4: Commit empty directories | |
| # ============================================================ | |
| find . -type d -regex ``./[^.].*'' -empty -exec touch {}"/.gitignore" \; | |
| git add . | |
| git commit -am "Adding empty directories" | |
| git push -u gitlab master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment