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.

Related articles

Andrew Fletcher17 Feb 2024
Update a git feature branch to the latest branch (master)
In our projects, team members frequently generate new Git branches linked to the same Jira number, resulting in cluttered and disorganised structures that can pose challenges for both current and future developers. For instance:Jira: ABC-123Ticket work: Reformat headersOver time, these branches...
Andrew Fletcher12 Oct 2023
What the following git commands do...
git reset, git revert, and git cherry-pick are three Git commands used for different purposes related to managing your version control history. Here's a brief overview of each command:git reset git revert git cherry-pick&nbsp;Snapshotgit revertis to roll back to a previous version of the repo...
Andrew Fletcher29 Sep 2023
Adding a Git repo to a server
git clone git@bitbucket.org:{username}/{repo}.gitAnd I was unceremoniously delivered the following errorfatal: could not create work tree dir '{project}': Permission deniedMy initial thought was the error due to server permission... being sudo.&nbsp; This was tested by running the commandsudo git...