How To Change Old URL Of Your SVN Repository To New

Step-1

In the last couple of years, there have been some pretty substantial changes in the URL structure of git repositories.A long time ago, people used to have their SVN repositories on the same machine with all their other git repositories, and they would constantly change or add new repositories to those old ones. They would tinker with URLs and such to keep upwardly mobile.Eventually, they started using a web interface to push things between their SVN repos — sort of like github-like apps for git.The more recent versions use static URLs for all repos (like gitlab does). This keeps everyone from messing up the url over time by accident (or intentionally) pushing to wrong repository — because things might be added or removed from old repo — which is a bad thing when you are doing things like adding new lines of code into your app that you haven’t tested or changed before!So as a final step, let us look at how we can change the URL of our SVN repository:Look at your svn repo’s URL in your web browser (or if you don’t have any web browser, then use your terminal): http://my-svn-repo.gitlab.com/myrepo/myrepo.git Look at each branch name: myrepo/ > my-repo-1 > my-repo-2 > … > my-repo > gitlab/ > my repository In GitLab we use <-><-> as it makes it intuitive for non Git users . And I guess it works for most other Git repositories too (though some people prefer a different convention). Let us see what happens when we check the URL: https://gitlab.com//?path= Or https://gitlab.com/?path=gitlab/myrepository?branchname= Here is also a GitLab user name and is one of the branches we pushed up: And here we can see that has created this branch called “my_rep_1”. Let us verify this by checking out this branch: And since we don’t have any branches there that point to “my_rep_1”. Since “My Repository” doesn’t have any branches pointing at it, let us check out

Step-2

Step-2: If you need any help with SVN, please post a comment here.If you are looking for an easy way, or even a free way to get into SVN, then the following steps might be of interest to you:1. Download the latest version of git:git is a distributed source code management system (MS-DOS) that allows you to work with multiple versions of the same project in one single location. It handles patching, merging and rebasing, both for programming and for text backups.  This is probably enough to get started but if you want more tools and features, then check out git-core , git-remote , and gitattributes .2. Download the below script from GitHub: scp .git .ssh (Note: I am using it from my home server so I can change IP address easily).3. Copy contents of above script on your computer (or download it from GitHub) to your clone repository directory. This script will fetch some information about your project from GitHub and store them in a file called .git/info/all_refs/HEAD/refs They will be stored on your server as well as in your cloned repository directory. You may have copies on other computers as well so feel free to share them with us too!4. Open up SSH session in local machine and run this command: ssh -l [email protected] “cd ; git config –global user .gitconfig && cat /.gitconfig” “cd ; git config –global branch master && cat /.git/info/all_refs/HEAD/” “cd ; rm -rf “$(pwd)/$(basename $1); exit 0” “echo ‘exit 1’ > /dev/null”‘5.) Once done close SSH session and delete files in your clone repository directory (if they are there at all). Now we have our new URL or rather, a new IP address that we can use to access our own copy of Git repositories via SSH login (our old one is still available but will no longer work). Run git config –global user username .gitconfig && cat $HOME/.ssh/authorized_keys This should open up an SSH

Step-3

Repository URLs are a pain. Let’s look at how to migrate from old url of SVN repository to new in a clean way.First, you will need to get access to your source code repository (if you don’t have it yet, it is probably generated by your CI system).Next, you need to install git on the server. If you have used Git in the past using an older version of Git, you may not have installed git on the server (it is probably installed already). In that case, installing git on the server is as easy as running git-installer –help and telling it where to install git.Now type:git config –global user.email “[email protected]” git config –global user.name “[email protected]”The above command will allow you to clone your repository from your own machine into the server with its password set up for that account and give it access to all of its files. That will be safer than cloning from a remote URL, but still add complexity if you want to share your source code with someone else on your team without letting them know about their own copy (which can be done by adding another permission for clone ).5. ConclusionSVN repository is one of the oldest tools for self-hosting of source code, and indeed one of the oldest tools for self-hosting any software. It is used by a large number of software companies and I’m sure there’s some number amongst us that have a SVN repository. SVN repositories can be used to host Git repositories, too, but they are usually hosted on servers that are not reachable via public internet.What you should do is to get yourself a reliable hosting service (we use DigitalOcean), preferably through public internet, and create your own private network between your PC and server. Then start creating new git branch (for example: master) on your own machine using SVN server.You can then simply clone your repository and push it to your own private network as follows:git clone ssh://[email protected]/some_svn_repository cd some_svn_repository git checkout -b branch_name git pull ssh://[email protected]/some_other_branch git push origin branch-name ssh://[email protected]/some_other_branch The last step above will create remote branch in the remote repository from which you will be able to push changes again and again as usual (e g : git pull -u origin master ). If you are already familiar with SVN server, then by all means, don’t forget to check built in “git add” command before doing anything else!