GIT - move a full git repository from one remote sever to another one

Copied from

Let’s call the original repository ORI and the new one NEW, here are the steps required to copy everything from ORI to NEW:

  1. Create a local repository in the temp-dir directory using:

git clone <url  to ORI repo >  temp-dir
clone ori repository
  1. Go into the temp-dir directory.

  2. To see a list of the different branches in ORI do:

git branch -a
git branch-a
  1. Checkout all the branches that you want to copy from ORI to NEW using:

git checkout branch- name
checkout-branches
  1. Now fetch all the tags from ORI using:

git fetch --tags
git-fetch-tags
  1. Before doing the next step make sure to check your local tags and branches using the following commands:

git  tag

git  branch -a
git-tag-and-git-branch-a
  1. Now clear the link to the ORI repository with the following command:

git remote rm origin
  1. Now link your local repository to your newly created NEW repository using the following command:

git remote add  origin <url toNEW repo>
  1. Now push all your branches and tags with these commands:

git push origin  --all


git push  --tags
end-result
  1. You now have a full copy from your ORI repo.

Command line instructions from GITLAB

Git global setup

git config --global user.name "Lam Hung NGUYEN"
git config --global user.email "lamhung81@gmail.com"

Create a new repository

git clone 
https://gitlab.com/lamhung81/auvfirmware.git

cd auvfirmware
touch README.md
git add README.md
git commit -m "add README"

git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin 
https://gitlab.com/lamhung81/auvfirmware.git

git add .
git commit -m "Initial commit"

git push -u origin master

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin 
https://gitlab.com/lamhung81/auvfirmware.git
git push -u origin --all
git push -u origin --tags

Last updated

Was this helpful?