0

We are using Git from one server. Same server is migrated to Azure.

After complete migration from current server to cloud server, I need to initialize git in cloud server with same GitHub repository which we were using in old server. Can anyone suggest some solution for this?

I have 3 example solutions:

  1. Remove the master branch in GitHub repo. push the code from cloud server to GitHub.
  2. Initialize git in cloud server and merge git and GitHub.
  3. When migrating code to cloud server. Migrate .git folder also.

Which solution is better from above 3? Or any other solution I can follow.

Clijsters
  • 4,031
  • 1
  • 27
  • 37
Swaroop
  • 9
  • 1
  • 4
  • Can you add a second remote (`gti remote add azure URL`) to your local git repo and do a push? You should then get an perfect copy of the repo. – Kris Sep 03 '18 at 10:18
  • Thanks Kris. But we have to use same remote repo which we had used for Old Server. – Swaroop Sep 03 '18 at 10:24
  • 1
    *"But we have to use same remote repo which we had used for Old Server"* what does that mean? The Name of a remote repo is a local property and can be changed easily... – Timothy Truckle Sep 03 '18 at 11:04
  • 2
    Possible duplicate of [How to migrate GIT repository from one server to a new one](https://stackoverflow.com/questions/1484648/how-to-migrate-git-repository-from-one-server-to-a-new-one) – Clijsters Sep 03 '18 at 11:39
  • You can use multiple remote and they can be called anything you like. You can also add multiple URL's to the same remote, e.g. `git remote set-url --add origin another-server.com/project` – Kris Sep 03 '18 at 12:22
  • @Swaroop has your problem been solved? If so, you can add the solution as answer and mark it. – Marina Liu Sep 09 '18 at 06:38

1 Answers1

0

You can migrate git repository from one server to another, even it is on Azure.

Below procedure migrate the repo as is, including branches, tags, commit history.

Clone the old repo using --mirror option to the old-repo folder.

git clone --mirror <oldServerURL> old-repo

Create an empty repo in the new server and get the git repo URL.

Add new remote and name it as AzureRepo, and using new git repo URL

cd old-repo
git remote add AzureRepo <AzureRepoURL>

Push everything to AzureRepo remote.

git push -f --tags AzureRepo refs/heads/*:refs/heads/*
Jijo John
  • 1,368
  • 2
  • 17
  • 31