Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#Once your local git can communicate with the gitlab server you can start migrating:
#Inspired from https://john.albin.net/git/convert-subversion-to-git
#First got to your gitlab and add a new project (in this tuto : YOUR_GITLAB_REPO.git)
#check out your svn project, right click in it and run git bash here to run the following command :
#Download all author commit data to update it to Git standard:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
#update the authors-transform.txt file with the git format e.g:
vi authors-transform.txt
username = FirstName lastName <YOUR_EMAIL@YOUR_COMPANY.com>
#:wq(to save and quit vi)
#Transform the svn repos into a temporary local git(~/temporary-git-project) with the updated author infos
#this temporary-git-project is added to your document folder in windows
git svn clone https://YOUR_SVN_REPOSITORY --no-metadata -A authors-transform.txt ~/temporary-git-project
#Add the svn-ignore files as git-ignore files :
cd ~/temporary-git-project
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn ignore to .gitignore.'
#Create a temporary local bare git repository
git init --bare ~/temporary-local-git.git
cd ~/temporary-local-git.git
git symbolic-ref HEAD refs/heads/trunk
#push our temporary locale git project to the new bare git repository
cd ~/temporary-git-project
git remote add bare ~/temporary-local-git.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
#rename the trunk to master (git naming convention)
cd ~/temporary-local-git.git
git branch -m git-svn master
#update bare git remote origin to the company gitlab url
cd ~/temporary-local-git.git
vi config
[core]
repositoryformatversion = 0
filemode = false
bare = true
symlinks = false
ignorecase = true
[remote "origin"]
url = git@gitlab.YOUR_COMPANY.com:YOUR_GITLAB_REPO.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
#:wq(to save and quit vi)
#push the temporary git to your gitlab project (remote url added above)
cd ~/temporary-local-git.git
git push -u origin --all
git push -u origin --tags
#Delete all temporary files
rm -Rf ~/temporary-local-git.git
rm -Rf ~/temporary-git-project
#clone Gitlab git repository into your new working copy folder
cd C:/Git/
git clone git@gitlab.YOUR_COMPANY.com:YOUR_GITLAB_REPO.git
# Cloning into 'YOU_PROJECT'...
# Enter passphrase for key '~/.ssh/id_ed25519':
# remote: Enumerating objects: 412, done.
# remote: Counting objects: 100% (412/412), done.
# remote: Compressing objects: 100% (182/182), done.
# remote: Total 412 (delta 155), reused 412 (delta 155)
# Receiving objects: 100% (412/412), 891.35 KiB | 15.37 MiB/s, done.
# Resolving deltas: 100% (155/155), done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.