I recently moved one of my Git repositories to a new location and needed to change the URL of my local checkout. There are a few ways to go about this, the easy way and the hard way. The hard way involves a search and replace of all your .git files for the repo, seems kind of silly to me. The easy way is a nice Git command to change the URL.
git remote set-url origin git://path.to.repo
This is pretty simple. For remote repositories on Github or BitBucket you can simply enter the URL for your repo. You’ll need to commit and a push to the new origin and then you’re all set. One other quick tip, if you have new credentials in your new Git repository, you can also add your username to the URL.
git remote set-url origin myUsername@git://path.to.repo
It’s that simple to change the remote repository in Git.