Skip to content

Instantly share code, notes, and snippets.

@jduhls
Created December 21, 2017 22:47
Show Gist options
  • Save jduhls/b160fa1809d1afa8254d0819b0cb069f to your computer and use it in GitHub Desktop.
Save jduhls/b160fa1809d1afa8254d0819b0cb069f to your computer and use it in GitHub Desktop.
Migrate a git repo
mkdir TEMP_REPO_FOLDERNAME # create a new folder
cd TEMP_REPO_FOLDERNAME
git init --bare .git # create a bare repo
git remote add origin SOURCE_REMOTE_URL # add a remote
git fetch origin refs/heads/*:refs/heads/* # fetch heads
git fetch origin refs/tags/*:refs/tags/* # fetch tags
git init # reinit work tree
git checkout master # checkout a branch
git remote rm origin # remove remote repo url
git remote add origin NEW_REMOTE_URL # new remote url
git push -u origin master # now push master
git push --all # now push all other branches
git push --tags # oh, and don't forget your tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment