====== To see how branches relate ====== $ git log --oneline --decorate --graph --all * c2b9e (HEAD, master) made other changes | * 87ab2 (testing) made a change |/ * f30ab add feature #32 - ability to add new formats to the * 34ac2 fixed bug #1328 - stack overflow under certain conditions * 98ca9 initial commit of my project Or use "gitk --all" ====== Generate patch and apply to branch with different commit history ====== Generate patches for local commits from origin/1.x $ git format-patch -k -o ~/patches_dir/ origin/1.x Check if a forced update is pending $ git fetch --dry-run remote: Enumerating objects: 26, done. remote: Counting objects: 100% (26/26), done. remote: Compressing objects: 100% (15/15), done. remote: Total 26 (delta 12), reused 21 (delta 7), pack-reused 0 Unpacking objects: 100% (26/26), done. From https://somerepo + 1ec508d...c046c5f 1.x -> origin/1.x (forced update) Update local branch when we know there is going to be a forced update $ git checkout master # Needs to be performed before doing fetch $ git fetch $ git branch -D 1.x $ git checkout -b mybranch-1.x origin/1.x Apply patches to branch $ cat ~/patches_dir/* | git am -k Script to automate fetching and re-applying patches #!/bin/sh localbranch=mybranch-1.x remotebranch=1.x patchdir=~/patches_dir repodir=~/the_cloned_repo # Generate patches # git format-patch -k -o "$patchdir" origin/$remotebranch ( cd $repodir # Apply patches git checkout master # Needs to be run before fetch git branch -D $localbranch-old git branch -m $localbranch $localbranch-old git fetch git checkout -b $localbranch origin/$remotebranch cat "$patchdir"/*.patch | git am -k ) ====== Update intermediary bare repo ====== Found some good info here. \\ [[https://stackoverflow.com/questions/3382679/how-do-i-update-my-bare-repo|How do I update my bare repo]] First fetch from the upstream server git fetch Then you need to update any branches that you want to expose to the downstream repositories. \\ Examples for master, 13.0 and all remote branches. \\ Avoid *:* if upstream repo is very big and you want to limit the branches used by downstream repositories. git fetch origin master:master git fetch origin 13.0:13.0 git fetch origin '*:*'