Skip to content

Instantly share code, notes, and snippets.

@xarmengol
Created February 19, 2017 11:00
Show Gist options
  • Save xarmengol/992ae843113818cb4a343f91bb38c4a8 to your computer and use it in GitHub Desktop.
Save xarmengol/992ae843113818cb4a343f91bb38c4a8 to your computer and use it in GitHub Desktop.
Moving a git bare repository to a new server
// 1. Creation of a new bare and shared repository
git init --bare --shared repo.git
// 2. Moving code from old repo to new one
// 2.1. Locally clone of the old repo
git clone user@10.10.10.10:/opt/git/repo.git
// 2.2. Web add a new remote repo origin to the new cloned local repo:
git remote add neworigin newuser@20.20.20.20:/opt/git/repo.git
// We can check that now we have two remotes: origin and neworigin, one pointing to 10.10.10.10 and the other pointing to 20.20.20.20:
git remote -v
// 2.3. Push repository to neworigin remote
git push neworigin --all
// Not in my case, but if it is wanted to move also all created tags:
git push neworigin --tags
// 2.4. We can test that the new repostory is ok, by cloning it to new local location
git clone newuser@20.20.20.20:/opt/git/repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment