Mirror repository to Gitlab for External CI usage

  1. Generate Access Token (read/write permissions to repo) (https://gitlab.com/profile/personal_access_tokens)
  2. Take a small server and install repository (git clone original-repo.com)
  3. Install Github Hub (https://github.com/github/hub)
  4. Create file with the following contents (it ensures we can mirror all branches and tags).
echo "updating repo"echo "checking out all remote branches locally"
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote" 2>&1 | grep -v "already exists"; done
echo "fetching updates"
git fetch --all
git pull --all
echo "updating all branches from remote"
hub sync 2>&1 | grep -v "was deleted on origin, but appears not merged into 'master'"
echo "push to gitlab"
git push --all https://oath2:[token]@gitlab.com/[user]/[project].git
git push --tags https://oath2:[token]@gitlab.com/[user]/[project].git
* * * * * cd /var/www/[project-dir]; bash mirror.sh; sleep 25; bash mirror.sh;
remote: error: cannot lock ref 'refs/heads/feature/[branch-name]': unable to resolve reference 'refs/heads/feature/[branch-name]'remote: error: cannot lock ref 'refs/merge-requests/11/merge': unable to resolve reference 'refs/merge-requests/11/merge'remote: error: cannot lock ref 'refs/pipelines/996296': unable to resolve reference 'refs/pipelines/996296'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store