1

Maybe my question is not well-formed.
The situation is this: we have 3 public branches: dev, qa, master.
I need to commit an urgent fix to the master, but the dev and the qa branches are already ahead of the master by a few commits.

What is the cleanest method to make a patch, and apply it to the master branch, as well as to all the branches?

EDIT:
Since many comments suggested cherry-picking, I would like to emphasize that I haven't committed the fix yet. I want to avoid cherry-picking, so if there's a better way of doing it, I would be happy to hear (maybe commit the fix on the master and then rebase qa and dev)

user1102018
  • 4,369
  • 6
  • 26
  • 33
  • possible duplicate of [How to merge a specific commit in git](http://stackoverflow.com/questions/881092/how-to-merge-a-specific-commit-in-git) – OneOfOne Jul 03 '14 at 13:25
  • On which branch ist your commit for the fix ? – rangalo Jul 03 '14 at 13:26
  • @rangalo I haven't written the bug fix yet. I will write it wherever it will require the least mess in merging. – user1102018 Jul 03 '14 at 13:29
  • @OneOfOne thanks for the comment, but I don't like cherry picking. So since I haven't committed the fix yet, I'm interested to know if there's a way to do that without cherry-picking. Maybe committing to the master and then rebasing the qa and dev branches? – user1102018 Jul 03 '14 at 13:31
  • 1
    Look at the answer by Gergo Erdosi. It would be best for you to start a hotfix branch from the last stable master and after the hotfix merge it back to master and dev. Search for hotfixes in the following page http://danielkummer.github.io/git-flow-cheatsheet/ – rangalo Jul 03 '14 at 13:32

2 Answers2

4

You can create a hotfix branch that is merged off from master and then merged back into master and develop. You can read more about hotfix branches here:

May branch off from: master Must merge back into: develop and master Branch naming convention: hotfix-*

Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.

The essence is that work of team members (on the develop branch) can continue, while another person is preparing a quick production fix.

Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
  • Thanks. I tried this method. I created a hotfix branch from the master, fixed, committed and merged into the master. Now i'm trying to merge the hotfix branch into the qa branch but I get lots of conflicts (as I stated in my question, qa branch is ahead of master). Any ideas? – user1102018 Jul 03 '14 at 13:55
0

cherry-pick an individual commit from dev to master.

gbjbaanb
  • 51,617
  • 12
  • 104
  • 148