Das Erstellen eines Git repositories mirrors ist einfach: git clone --mirror REPO_URL Möchte man nun diesen mirror auch noch woanders haben dann geht dies so: git clone --mirror REPO_URL cd mirrored-local-path git push --mirror DIFFERENT_REPO_URL Laufende Updates: cd mirrored-local-path git remote update --prune git push --mirror DIFFERENT_REPO_URL Hat man nun im neuen Ziel [refspecs](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec) die nicht erwünscht sind sieht man so eine Fehlermeldung: ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref) ! [remote rejected] refs/pull/4/head -> refs/pull/4/head (deny updating a hidden ref) ! [remote rejected] refs/pull/5/head -> refs/pull/5/head (deny updating a hidden ref) ! [remote rejected] refs/pull/6/head -> refs/pull/6/head (deny updating a hidden ref) ! [remote rejected] refs/pull/9/head -> refs/pull/9/head (deny updating a hidden ref) In diesem Fall werden pull requests nicht erlaubt zu pushen. Leider half [Git Howto: Mirror a GitHub repo without pull refs](https://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html) nicht. Wie auch. Die refs werden NACH dem clone angepasst und sind daher in dem mirror noch vorhanden. Leider will die [-c option](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt--cltkeygtltvaluegt) für `git clone -c remote.origin.fetch=+refs/changes/*:refs/changes/* https://some.tld/repo.git` nicht so richtig. Zumindest geht es bei mir nicht mehrere refs anzupassen. Bei einer geht es aber die allgemeine refspec ist trotzdem vorhanden. Somit ist auch wieder alles im mirror. Am Ende geht es nur über das Entfernen von den unerwünschten refs: git show-ref | cut -d' ' -f2 | grep 'pull/' | xargs -r -L1 git update-ref -d Wobei das `pull/` im grep entsprechend angepasst werden muss damit das gewünschte entfernt wird. Am Ende kam folgendes script zur Autmation raus. Voraussetzung ist ein initiales `git clone --mirror` cd mirrored-local-path git remote update --prune git show-ref | cut -d' ' -f2 | grep 'pull/' | xargs -r -L1 git update-ref -d git push --mirror DIFFERENT_REPO_URL Dec 30 2020 © https://www.bananas-playground.net 2000 - 2024