Skip to content

Instantly share code, notes, and snippets.

@mattgibson
Created June 5, 2012 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattgibson/2875045 to your computer and use it in GitHub Desktop.
Save mattgibson/2875045 to your computer and use it in GitHub Desktop.
Copying a distinct feature or hotfix branch from one release branch to another
# Example scenario: two Moodles - one 2.1.x, one 2.2.x. Fix is on 2.2.x and we want to backport it
# to 2.1.x. Each moodle is a separate repo roughly following the gitflow approach and there is a
# separate develop and release branch for each one.
# Push to gihub from the repo that has the fix branch
# Fetch from github from the repo that needs it (assuming we have one repo for each release branch)
# Checkout the fix branch as a new local branch
git checkout -b localfix origin/fixbranch
# Find the SHA1 of the commit where fix diverged from master or develop (the last non-fix commit)
# Rebase the localfix onto the target branch
git rebase --onto targetbranch <SHA1> localfix
# Merge it nicely
git checkout targetbranch
git merge --no-ff localfix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment