From 4525956c0dd0a21b8c296d6a4e5d67ee7f3b0ea9 Mon Sep 17 00:00:00 2001 From: Daniel Spittank Date: Mon, 8 May 2023 20:23:05 +0200 Subject: [PATCH] =?UTF-8?q?Quick=20Tip=20zum=20synchen=20von=20Tags=20in?= =?UTF-8?q?=20Forks=20(Git)=20hinzugef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Docker/aufraeumen.md | 0 docs/Quick Tips/Git/sync-tags-branches.md | 58 +++++++++++++++++++ .../Proxmox/aufraeumen.md | 0 3 files changed, 58 insertions(+) rename docs/{Quicktips => Quick Tips}/Docker/aufraeumen.md (100%) create mode 100644 docs/Quick Tips/Git/sync-tags-branches.md rename docs/{Quicktips => Quick Tips}/Proxmox/aufraeumen.md (100%) diff --git a/docs/Quicktips/Docker/aufraeumen.md b/docs/Quick Tips/Docker/aufraeumen.md similarity index 100% rename from docs/Quicktips/Docker/aufraeumen.md rename to docs/Quick Tips/Docker/aufraeumen.md diff --git a/docs/Quick Tips/Git/sync-tags-branches.md b/docs/Quick Tips/Git/sync-tags-branches.md new file mode 100644 index 0000000..7de1386 --- /dev/null +++ b/docs/Quick Tips/Git/sync-tags-branches.md @@ -0,0 +1,58 @@ +# Branches und Tags in einem Fork von Upstream synchen + +Manchmal ist es notwendig, einen Fork auf den aktuellen Stand zu bringen und dabei auch die Branches und Tags aus dem Upstream zu übernehmen, +z.B. für Mkdocs Material Insiders notwendig, da die Pull-App versagt... + +1. Fork lokal clonen +2. Upstream Remote anlegen + ``` bash + git remote add upstream + git pull upstream + ``` +3. Skript zur Synchronisation anlegen (sync.sh) [^1]: + ``` bash + ## Checkout all branches from remote as tracking branches. Based on https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches/6300386#6300386 + + UPSTREAM=$1 + MYREPO=$2 + + usage() { + echo "Usage:" + echo "$0 " + echo "" + echo "Example which ensures remote named 'maxandersen' have all the same branches and tags as 'origin'" + echo "$0 origin maxandersen" + exit 1 + } + + if [ -z "$UPSTREAM" ] + then + echo Missing upstream remote name. + usage + fi + + if [ -z "$MYREPO" ] + then + echo Missing target remote name. + usage + fi + + read -p "1. This will setup '$MYREPO' to track all branches in '$UPSTREAM' - Are you sure ?" -n 1 -r + + if [[ $REPLY =~ ^[Yy]$ ]] + then + for brname in `git branch -r | grep "$UPSTREAM" | grep -v master | grep -v HEAD | sed -e 's/.*\///g'`; do git branch --track $brname $UPSTREAM/$brname ; done + fi + + read -p "2. This will push all local branches and tags into '$MYREPO' - Are you sure ?" -n 1 -r + + if [[ $REPLY =~ ^[Yy]$ ]] + then + git push --all $MYREPO + git push --tags $MYREPO + fi + ``` +4. synchronisieren mit ``` ./sync.sh upstream origin ``` + + +[^1]: How to update my fork to have the same branches and tags as the original repository on github? [Stackoverflow](hhttps://stackoverflow.com/questions/15779740/how-to-update-my-fork-to-have-the-same-branches-and-tags-as-the-original-reposit) \ No newline at end of file diff --git a/docs/Quicktips/Proxmox/aufraeumen.md b/docs/Quick Tips/Proxmox/aufraeumen.md similarity index 100% rename from docs/Quicktips/Proxmox/aufraeumen.md rename to docs/Quick Tips/Proxmox/aufraeumen.md