This blog explains the process I have followed while moving one of code branch of one of the projects to Gitlab.
SVN to Git migration can be done using the git-svn command in Git. Documentation about this command can be found from here.
My Company svn repository can be accessed using two ways
- svn+ssh://192.168.x.x/usr/local/svnroot/branches/PROJECT/PROJECT_BRANCH
- http://svn.companyName.net/repos/svnroot/branches/PROJECT/PROJECT_BRANCH
SVN to GIT migration can be done using one of the above-mentioned URLs. Git can be installed and configured to use its inbuilt SSH client or third party ssh client (https://6xgate.github.io/TortoisePlink/ )
First of all, this process should be run in a server where the system does not go idle. I have tried this on my PC. But when I have locked the PC, it crashes. Therefore I have tried this in one of our internal server.
I have tried to get SVN revision history when the Project main branch was created. (at 2015).
I have first tried to clone the git repository using the 1st URL. When cloning the svn repository, it is trying to access a deeper level to get svn changes history. I have access to those deeper level, git-svn requiring ssh password for each new connection created to access svn history. This needs to enter the password more than 100 times. (As per my investigation, this can be avoided by configuring private-public ssh key. : But I did not try that.)
Due to an authentication error, I have tried to use the second URL. This worked well and It required a password only once.
Although in both processes, it requires a lot of time to clone SVN repository to Git with history.
Reference url :
Part 1: Move code to empty Git repository
Method 1
git svn clone --no-minimize-url http://svn.companyName.net/repos/svnroot/branches/PROJECT/PROJECT_BRANCH -r541750:HEAD
Note: I have added two parameters with this command.
- --no-minimize-url - Passing --no-minimize-url will allow git-svn to accept URLs as-is without attempting to connect to a higher level directory. This option is off by default when only one URL/branch is tracked (it would do little good).
- -r541750: HEAD - Using this command, we can get revision history starting from 541750 to HEAD. This will reduce the time to load all the file history.
git svn fetch
If the first command is failed, using fetch, the user can resume the process using “git svn fetch”. (git svn clone runs init and fetch)
git svn rebase
This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it. This works similarly to svn update or git pull except that it preserves linear history with git rebase instead of git merge for ease of dcommitting with git-svn.
git remote add master http://gitlab.companyName.net/project-group/sub-group/project_name.git
git push --set-upstream master master
git commit -m "Initial commit of SVN to GIT"
//Update master & after clone all svn changes merge
git svn rebase
// git master update
git push --all
Part 2: Sync between GitLab and SVN repository
If you already have moved code to GitLab and but still using SVN repository, then you can update
the GitLab repository using the following commands.
the GitLab repository using the following commands.
git svn rebase
This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN)
work against it.
This works similarly to svn update or git pull except that it preserves linear history with git rebase
instead of git merge for ease of dcommitting with git-svn.
work against it.
This works similarly to svn update or git pull except that it preserves linear history with git rebase
instead of git merge for ease of dcommitting with git-svn.
git svn dcommit
Commit each diff from the current branch directly to the SVN repository, and then rebase or
reset (depending on whether or not there is a diff between SVN and head).
This will create a revision in SVN for each commit in Git.
reset (depending on whether or not there is a diff between SVN and head).
This will create a revision in SVN for each commit in Git.
When an optional Git branch name (or a Git commit object name) is specified as an argument,
the subcommand works on the specified branch, not on the current branch.
the subcommand works on the specified branch, not on the current branch.
Reference: https://git-scm.com/docs/git-svn#git-svn-emdcommitem
Comments
Post a Comment