A personal blog about computer science topics.

Create a GitHub Mirror
Provide easy access to external repos via GitHub
Posted on Dec 25 2016 ~ 1 min read
#github  #bash  #programming 


Many big repositories are not hosted on GitHub, but do have a official mirror like linux, git or ghc. The purpose of these mirrors is to provide an easy access (lower the barrier) to repositories that are not hosted on GitHub. There are many repositories that do not offer a official mirror. Follow this short article, if you want to know how to create a mirror, to provide an easy access to external repositories as well.


Step 0: Clone the repository you want to mirror.
Step 1: Add your empty remote GitHub repository as mirror.

# example for valgrind
git svn clone svn:// valgrind
cd valgrind
git remote add mirror


Step 2: Create a mirror.bash file with all repositories you want to mirror and copy the contents below. Update the GIT_PATH and choose your mirrors.

while :
function update {
cd $GIT_PATH/$2

if [ $1 = "svn" ]; then
    git svn rebase origin/master
    git rebase -s recursive -X theirs origin/master

git push -f mirror master

update "svn" valgrind

# other examples
# update "git" grub
# update "git" nano
# update "svn" codeblocks

# repeat every 2 hours
sleep 2h

Step 3: Make the script executable chmod x+u and run it. Example: Valgrind mirror