Skip to main content

Moving a Git repo due to a change of agencies

 

Steps to change the repo:

1. Create a temporary directory

Create a temporary directory obviously where your other sites are located locally.  For me, this is in the Sites directory.

mkdir temp-dir

 

2. Clone

Begin by cloning the current repo in the directory generated above

username@25.123.212.231:/opt/git/proj.git

 

3. Directory

Go into the temp-dir directory and view see a list of the different branches:

git branch -a

A response will be something similar to

* deploy
  remotes/origin/HEAD -> origin/deploy
  remotes/origin/deploy
  remotes/origin/dev
(END)

 

4. Checkout & tags

Check out all the branches that you want to copy from ORI to NEW using the following command:

git checkout {branch-name}

Move on to tags using

git fetch --tags

Let's cross-check your local tags and branches using the following commands:

git tag
git branch -a

 

5. Separation and connecting to a new repo

You can clear the link to the repository using the command:

git remote rm origin

Ok, it's time to link your local repository to your new repository using:

git remote add origin <url to NEW repo>

Time to push your branches and tags:

git push origin --all
git push --tags

 

Congratulations as now you have a full copy from your old repo.