Skip to content

Instantly share code, notes, and snippets.

@rx
Created May 27, 2021 20:59
Show Gist options
  • Save rx/8b4d15672d233e9f2e20e59a9742e597 to your computer and use it in GitHub Desktop.
Save rx/8b4d15672d233e9f2e20e59a9742e597 to your computer and use it in GitHub Desktop.
Setting up a mirrored repository on Github

I ran into some issues trying to mirror a repository on Github. This Gist outlines what changes were needed to get it working.

I was attempting to follow these instructions: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/duplicating-a-repository#mirroring-a-repository-in-another-location

The problem was that the pull refs from Github generate error/warnings (and lots of them). Here is more about that: https://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html

After issueing the git clone --mirror call I ran the following command to remove the pull request refs: git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d

I ended up alterning my git config -e to the following:

  [core]
        repositoryformatversion = 0
        filemode = true
        bare = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://github.com/rx/presenters
        fetch = +refs/heads/*:refs/heads/*
        fetch = +refs/tags/*:refs/tags/*
        mirror = true
[remote "mirrors"]
    url = https://github.com/coprl/coprl
    mirror = true
    skipDefaultUpdate = true

So now I can keep the mirror up to date:

git remote update git push mirrors

You can probably use the steps in the Github guide just as well, I just liked the syntax above better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment