You simply need to add new remote and than push your code to the new repo
git remote add origin2 <url>
git push origin2 <branch name>
Here is a scrip which im using to checkout all branches and than push them to the new remote
# first add the new rmeote
git remote add origin2 <new-url>
#!/bin/bash
# loop over all the original branches
# 1. check them out as local branches
# 2. set the origin as the track branch
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin2/} $branch
done
# now push all branches and tags
git push origin2 --all
git push origin2 --tags
What does the script do?
git branch -a
get a list of all the local branches
| grep remotes
The branch names are : 'remotes/origin/' so this will remove the remotes from the branch names
| grep -v HEAD | grep -v master
remove the master (current branch) and HEAD which is an alias to the latest commit