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 log graph showing commits per branch in one place
  • Git on godaddy - git-upload-pack not found
  • How can I review manually resolved conflicts in git (github, some app, InteliJ)
  • Merge local repository with Github repository discarding remote files
  • Git aliases - command line autocompletion of branch names
  • Why do I have to “clone” an existing Git repository to access it?
  • 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?

  • Which files generated by Autotools should I keep in version control repository?
  • Whoops, looks like something went wrong. error in Laravel 5 when trying to run on built in server
  • Using git (or some other VCS) at your company
  • Remove duplicate commits introduced after bad rebase(s)
  • Why Git fail to connect to local repository with Jenkins (bad config file)?
  • Bash in Git for Windows: Weirdness when running a command with CMD.exe /C with args
  • 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
    # go to 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


    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.