Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewspiers/15140acc1fb80f46e58f to your computer and use it in GitHub Desktop.
Save andrewspiers/15140acc1fb80f46e58f to your computer and use it in GitHub Desktop.
Applying patches to branches

if i have a fix that applies to multple branches say 4.1 4.2 and 4.5 branch, would this be the best way to apply the bug fix to branches...

[11:37] - clone dev branch git clone git@example.com:/project -b devrelease devfolder git add setup/example.sql git commit -m "Fixed the example bug" git push origin master note down the sha1 code number

  • clone prod branch

git cherry-pick sha-example-number


Clone the repo if you haven't done so already For each branch that you need to patch:

  • Checkout the branch: git checkout 4.1
  • Make a new feature branch based on that branch: git checkout -b 'apply fix to 4.1'
  • Make the fix, and make a commit. (you might be able to cherry-pick if it is already in master)
  • Either send this to gerrit with git review, or git push. If you are going to git push, remember to push to the right branch, ie git push origin 4.1
  • Checkout the next branch you need to fix and repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment