Sauter Git Workflow : Make an hotfix - sauter-hq/git-guidelines GitHub Wiki

There are times where a release approved by the Quality Assurance, looking really stable still has a problem once deployed. For this you should create hotfixes, and here is how to do it:

SourceTree

  1. Create an hotfix on the basis of the very last published version (the "normal" case).
    E.g. you are currently developing the version 3.3, your very last published version (in branch master) is version 3.2. You now have to create an hotfix/patch for this version 3.2.

    • Click on the Git Flow button.
    • Choose the Git Flow action : Start New Hotfix

    Start a new Hotfix

    • Give a name to the hotfix branch with the following pattern <product-version>-patch-<patch-version> ( e.g. 3.2.1-patch-1 )
      * This creates a branch hotfix/-patch- ( e.g. 3.2.1-patch-1 ) on base of the latest

    Start a new Hotfix

  2. The rest of the workflow is the exact same thing in both cases.

    • Make the changes to fix the problem ( i.e Commits them)
    • Click on the Git Flow button.
    • Choose the Git Flow action : Finish Hotfix

    Finish hotfix

    • Let everything as default, eventually type a descriptive message for the tag.
      • This creates a tag for the hotfix, so that you can retrieve the hotfix version later, and it also merges the hotfix in master and develop. In case the merge in master or develop is not wanted, simply reset the branch to the commit just before.

    Finish hotfix

    • Push the tags and the master and develop branch to confirm that the hotfix was done.
  3. Create an hotfix on the basis of a previosly published version.
    E.g. you are currently developing the version 3.3, your very last published version (in branch master) is version 3.2.1 But you have to create an hotfix/patch for an earlier published version 3.2.

    • Click on the Tag list the 3.2 Tag

    • right click on the associated entry for the tag and select create branch

      Start a new Hotfix

    • Give a name to the hotfix branch with the following pattern <product-version>-patch-<patch-version> ( e.g. 3.2-patch-1 )

      Start a new Hotfix

  • Make the changes to fix the problem ( i.e Commits them)

  • Create a tag once everything is fixed

    ![Start a new Hotfix](pictures/start-new-hotfix-from-old-tag-new-branch-add-tag.jpg) 
    
  • If the fix needs to be merged in develop - Never merge in Master - :

    • Checkout Develop, select the tag of the patch (3.2-patch-1) and select merge with "create a new commit" option activated

      Start a new Hotfix Start a new Hotfix

  • Delete the hotfix branch:

    ![Start a new Hotfix](pictures/start-new-hotfix-from-old-tag-delete-branch.jpg) 
    
  • Push the tags and the develop branch to confirm that the hotfix was done.

Command Line

  1. Create an hotfix on the basis of the very last published version (the "normal" case).
    E.g. you are currently developing the version 3.3, your very last published version (in branch master) is version 3.2. You now have to create an hotfix/patch for this version 3.2.

    • Create an hotfix-branch with the following pattern <product-version>-patch-<patch-version> ( e.g. 3.2.1-patch-1 )
    git flow hotfix start v3.2.1-patch-1 
    
    Switched to a new branch 'hotfix/v3.2.1-patch-1'
    
    Summary of actions:
    - A new branch 'hotfix/v3.2.1-patch-1' was created, based on 'master'
    - You are now on branch 'hotfix/v3.2.1-patch-1'
    
    Follow-up actions:
    - Bump the version number now!
    - Start committing your hot fixes
    - When done, run:
    
         git flow hotfix finish 'v3.2.1-patch-1'
    
  2. The rest of the workflow is the exact same thing in both cases.

    • Make the changes to fix the problem ( i.e Commits them)

    • Finish the hotfix :

      git flow hotfix finish 'v3.2.1-patch-1'
      
      Summary of actions:
      - Latest objects have been fetched from 'origin'
      - Hotfix branch has been merged into 'master'
      - The hotfix was tagged 'v3.2.1-patch-1'
      - Hotfix branch has been back-merged into 'develop'
      - Hotfix branch 'hotfix/v3.2.1-patch-1' has been deleted
      
  • This creates a tag for the hotfix, so that you can retrieve the hotfix version later, and it also merges the hotfix in master and develop. In case the merge in master or develop is not wanted, simply reset the branch to the commit just before.

  • Push the tags and the master and develop branch to confirm that the hotfix was done.

  1. Create an hotfix on the basis of a previosly published version.
    E.g. you are currently developing the version 3.3, your very last published version (in branch master) is version 3.2.1 But you have to create an hotfix/patch for an earlier published version 3.2.

    • Then you have to create a branch yourself in the hotfix/ prefix with the following pattern <product-version>-patch-<patch-version> ( e.g. 3.2-patch-1 ) :
    git checkout -b hotfix/v3.2-patch-1 v3.2
    
    Switched to a new branch 'hotfix/v3.2-patch-1'
    

    Now the hotfix features of git flow works on it :

    git flow hotfix list
    
    * v3.2-patch-1
    
  • Make the changes to fix the problem ( i.e Commits them)
  • Create a tag once everything is fixed
git tag v3.2-patch-1
  • If the fix needs to be merged in develop - Never merge in Master - :

    • Checkout Develop, select the tag of the patch (3.2-patch-1) and merge it this way :
    git merge v3.2-patch-1
    
  • Delete the hotfix branch:

    git branch -d hotfix/v3.2-patch-1
    
  • Push the tags and the develop branch to confirm that the hotfix was done.