Move a git repository to another location.

Posted by peter on Wednesday, August 19, 2015
  1. Clone the the repository git clone https://code.google.com/p/my_repo cd my_repo

  2. List all local and remote branches. Note: All branches will be pushed later, both local and remote. git branch -a

  3. Track all remote branches. for remote in git branch -r | grep -v '\->'; do git branch –track ${remote#*/} $remote; done

  4. Add the new remote repository. git remote add new-origin git@github.com:user/my_repo.git

git remote -v

  1. Push all branches to the new remote repository location. git push -u –all new-origin

  2. Push all tags to the new remote repository location. git push –tags new-origin

  3. Remove or rename the old origin git remote rm origin  # or rename ‘git remote rename origin old-origin'

  4. Rename the new-origin. git remote rename new-origin origin

git remote -v


comments powered by Disqus