Search code examples
gitgithubgit-fork

Copy/fork a git repo on github into same organization


I have a repo on github that contains a web application that's deployed to two different domains. The application has slight logic forks here and there to behave differently depending on which domain it's deployed to.

It's come to the point to where I want to split it into two separate repos, one for each domain.

Github won't let me fork it into the same organization. Searching for "git duplicate repo" suggests I should bare clone and mirror push it, but that seems to be for keeping both repos in sync, which I don't want to do.

What's the best way to go about this? I'd like to preserve the old commit history in the new copy if possible.


Solution

  • Just create a new repository and push to it from your working copy:

    git clone [email protected]:me/myrepo-original
    cd myrepo-original
    git remote set-url origin [email protected]:me/myrepo-new
    git push origin master
    

    Now you have a new repository, myrepo-new, which is identical to myrepo-original.