There are many options out there for keeping track of your project updates, release versions and storing your code. Be it through Github, Bitbucket or a number of other services and from time to time you may decide you need to move a repository from one service to another. If you are anything like me you could have two dozen websites installed locally which you need to do work with on a regular basis so won’t want to go through setting up websites again (nightmare).
Up until recently the agency I work for used a combination of mainly Bitbucket but with some held with Github and decided to consolidate them under Gitlab instead.
The process I followed to update my local copies of these Dev sites was pretty simple;
- Open Terminal and navigate to the sites working directory, for example
$ /Applications/MAMP/htdocs/myproject
- Then I listed the existing remote URLs to check where they are currently pointed, and so whether they need to be updated (good to check that I hadn’t already updated it)
$ git remote -v origin git@bitbucket.org:USERNAME/REPOSITORY.git (fetch) origin git@bitbucket.org:USERNAME/REPOSITORY.git (push)
- Now change the remote’s URL from Bitbucket to Gitlab with the
git remote set-url
command.$ git remote set-url origin git@gitlab.com:USERNAME/REPOSITORY.git.git
- I then verified that the remote URL had been updated.
$ git remote -v origin git@gitlab.com:USERNAME/REPOSITORY.git (fetch) origin git@gitlab.com:USERNAME/REPOSITORY.git (push)
That wasn’t such a chore now was it? Finally you can grab any updates which may have been made to the repository since the last time you grabbed a copy by using git fetch