Mirror Dropdown Change from Push to Pull Not Working

Hi,

if the application cannot solve this, there’s another way to achieve this with native Git.

I had described this in this topic: Refreshing a Fork (the CLI ways).

A small cronjob on the CLI with that script should also work. I have been using this method for quite a while to sync everything between GitHub, GitLab, SVN repos and others.

Here’s an example we used in the past to sync from GitLab to GitHub (the other way around).

#!/bin/bash
REPO_HOME="/data/sync"
declare -A REPOS
# syntax is [github_repo]="gitlab_repo"
REPOS=([githubrepo]="gitlabgroup/gitlabrepo")
cd $REPO_HOME
for REPO_GITHUB in "${!REPOS[@]}"
do
	REPO_LOCAL=${REPOS[$REPO_GITHUB]}
        echo "### Processing repo $REPO_LOCAL"
        if [ ! -d $REPO_LOCAL ]; then
                git clone --bare --mirror https://gitlab.domain.org/$REPO_LOCAL.git $REPO_LOCAL
        fi
        (cd $REPO_LOCAL; git fetch --prune; git push --prune git@github.com:org/$REPO_GITHUB.git +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*)
done
# su - git
$ crontab -e
 
# Sync repos to github
*/5 * * * * /data/sync/github/create_and_sync > /dev/null 2>&1

Cheers,
Michael

1 Like