Transfer “authoritative” git repository from Github to a private github

My task is to move our repositories from public github to a private instance of github on our local net.

My thought is to move them with

  • Git - Push a folder after changing the remote?
  • How can I Remove .DS_Store files from a Git repository?
  • Sync two computers and also use git
  • How can I sync the documents of shareJS with a fileSystem
  • Let git ask for passphrase in separate window instead of terminal
  • Git: How do I set up SSH keys to access my remote repository from a second computer?
  • git clone --bare <github-repo-url>
    git push --mirror <local-github-url>
    

    During a transition time, I should be able to make the mirror update itself from the repository on the daddy github. (Or will I? I haven’t found a command in the UI to do an update.)

    Then I will delete the “authoritative” github repository, and the mirror will become authoritative.

    But how does that happen? Does each developer need to change the url for “origin” in .git/config?

    Will the mirror accept pushes that aren’t updates from its clone-parent?

  • Git: how to return to a past commit to start a branch keeping all commits?
  • git tracking submodule files from “super project”
  • Who pushed commits into remote repository?
  • How to replace corrupt Git objects with new ones created from my files, which are fine
  • How can I merge all the changes from 1 branch to another
  • Project structure and build system for .NET connected to git
  • 2 Solutions collect form web for “Transfer “authoritative” git repository from Github to a private github”

    Your process is almost perfect. The only thing was a missing --mirror parameter on the initial clone.

    # create the private repo
    ssh private-server
    mkdir -p /path/to/shared/repos
    git init --shared={whatever makes sense for your environment} /path/to/shared/repos/internalrepo.git
    exit
    # go to github.com and make the public repo readonly
    # create a local mirror
    git clone --bare --mirror $Github-URL github.git
    # now the local repo github.git contains all the stuff from the github repo
    cd github.git
    git push --mirror $Private-URL
    # Tell all developers to execute `git remote set-url origin  $Private-URL`
    # Done
    

    I would not leave the github repo open for changes, since it would not be clear to everyone in the project which repo is now the correct repo. You can still do it, if you run on the server-repo

    ssh private-server
    cd /path/to/shared/repos/internalrepo.git
    git remote add --mirror github $Github-URL
    

    and then regularly (like in a cron job)

    git fetch github # get new commits from github
    git remote prune github # drop branches, which are now deleted in the github repo
    

    Edit

    You also can use the local mirror to do the exchange. But there is no easy automated process, since git can’t decide neither what to do with deleted branches, nor what to do with diverged branches. Sou you need to keep a working repository where you regular fetch the stuff from the former github-repo, fetch the stuff from the internal repo, resolve diverging history and push this stuff back to the internal repo.

    The simplest process would be for the developers to clone the new (private) repo and go on from there.
    If they have any pending changes in progress in their former repo, they can export those as patches and apply them on the new locally cloned repo before pushing them back to the new origin. (See What is the difference between ‘git format-patch‘ and ‘git diff‘? and git format-patch man)

    Git Baby is a git and github fan, let's start git clone.