0

I'd like to move over a repo, with all its history and branches, to a fresh repo. I've been able to find ways to use a single branch as a basis for a new repo (git workflow - using one repo as the basis for another), but I can't figure out how I'd preserve all branches (and their histories, ideally). Is there a way to do this? or possibly a clever workaround so I don't lose my work on non-master branches?

Community
  • 1
  • 1
eirikir
  • 3,802
  • 3
  • 21
  • 39

2 Answers2

0

You can simply fork the repository on Github, which will make a complete copy of it as well as link the copy to the original for the purposes of generating pull requests to it.

cdhowie
  • 158,093
  • 24
  • 286
  • 300
0

Clone a fresh copy of your repo, using the --mirror flag:

$ git clone --mirror git://example.com/some-big-repo.git

This is a bare repo, which means your normal files won't be visible, but it is a full copy of the Git database of your repository, including all branches. Once cloned, set the origin to be your new repo, and push:

$ git remote set-url origin git://new.com/some-big-repo.git
$ git push

All branches will be transferred, and this method will work for any Git host, not just GitHub.

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101