Skip to content

Instantly share code, notes, and snippets.

@msmunoz-pricesmart
Created May 23, 2024 18:29
Show Gist options
  • Save msmunoz-pricesmart/411cda59f42301ee338cbf02160c7e26 to your computer and use it in GitHub Desktop.
Save msmunoz-pricesmart/411cda59f42301ee338cbf02160c7e26 to your computer and use it in GitHub Desktop.
Gitflow - Command line

GIT-FLOW

Using git commands:

How to create a Release candidate RC

  • Make sure you are in branch develop

    git checkout develop
  • Make sure developbranch is up to date from origin:

    git pull origin develop
  • Create a new release branch from develop:

    git checkout -b release/x.y.z
  • Make required changes like updating POM version and other required files. Once changes are in place, execute add and commit:

    git add .
    git commit -m "POM version updated"
  • Push release branch to remote repository:

    git push origin release/x.y.z
  • Deploy release branch in STAGE environment and execute required testing (QA test may include regression tests). This step considers all reviews and required functionality validations.

  • Once RELEASE CANDIDATE is approved and ready, merge it into master branch.

    git checkout master
    git pull origin master
    git merge --no-ff release/x.y.z
    
  • Create TAG to reference the new version in master:

    git tag -a x.y.z -m "Release version x.y.z"
    
  • Push changes and tag to remote repository:

    git push origin master
    git push origin x.y.z
    
  • Once RELEASE CANDIDATE has been merged to master merge it to develop branch to incorporate changes.

    git checkout develop
    git pull origin develop
    git merge --no-ff release/x.y.z
    git push origin develop
    
  • Delete RELEASE branch:

    git branch -d release/x.y.z
    git push origin --delete release/x.y.z
    

How to create a Hotfix HF

  • Make sure you are in branch master

    git checkout master
  • Make sure master branch is up to date from origin:

    git pull origin master
  • Create a new hotfix branch from master:

    git checkout -b hotfix/x.y.z
  • Make changes required to fix the issues. Apply required fixes in code. (Remember to update POM version) Then add and commit:

    git add .
    git commit -m "Fix applied to solve (issue) x.y.z"
  • Push hotfox branch to remote repository:

    git push origin hotfix/x.y.z
    
  • Publish hotfix in STAGEenvironment and execute required tests and validations to make sure hotfix is properly implemented.

  • Merge hotfix into masterbranch:

    git checkout main
    git pull origin main
    git merge --no-ff hotfix/x.y.z
    
  • Create TAG of the new version in master branch:

    git tag -a x.y.z -m "Hotfix version x.y.z"
    
  • Push master and TAGto remote repository:

    git push origin main
    git push origin x.y.z
    
  • Merge hotfix into developbranch to incorporate hotfix changes:

    git checkout develop
    git pull origin develop
    git merge --no-ff hotfix/x.y.z
    git push origin develop
    
  • Delete hotfix branch:

    git branch -d hotfix/x.y.z
    git push origin --delete hotfix/x.y.z
    

Using git-flow tool

  • Install `git-flow' tool

    • macOS:
      brew install git-flow
      
    • Debian/Ubuntu:
      sudo apt-get install git-flow
      
    • Windows: You can install Git Flow using the Git for windows installer.This includes GitFlow as an option during installation.
  • Initialize Git-Flow in the target repository. Make sure you navigate to the GIT repository you want to use and execute the following command:

    git flow init
    

    Follow instructions displayed to set up main and support branches. By default, main branches are main and develop.

Create Release Candidate RC using git-flow:

  • Initialize a new release:

    git flow release start x.y.z
    

    This command will create a new release branch from develop branch.

  • Execute requried changes and commit: Make required changes in code (i.e. update POM version) and commit those changes.

    git add .git commit -m "POM version updated"
    
  • Push release branch to origin:

    git push origin release/x.y.z
    
  • Deploy release in STAGE environment and make sure everything is working ok. Perform all required validations and tests.

  • Finish release: Once RC is approved then it can be finished. To do that execute the following command:

    git flow release finish x.y.z
    

    This command will:

    • Merge release branch into master branch.
    • TAG of the new version in master
    • Merge release branch into develop branch
    • Delete release branch
  • Push changes to remote repository:

    git push origin main
    git push origin develop
    git push origin --tags
    

Create Hotfix HF using git-flow:

  • Initialize a new hotfix:

    git flow hotfix start x.y.z
    

    This command will create a new release branch from develop branch.

  • Make required changes and commit: Make required changes in code (remember to include updating the POM version) and commit:

    git add .
    git commit -m "changes required - hotfix versión x.y.z"
    
  • Push hotfix to remote repository:

    git push origin hotfix/x.y.z
    
  • Deploy release in STAGE environment and make sure everything is working ok. Perform all required validations and tests.

  • Finish hotfix:

    git flow hotfix finish x.y.z
    

    This command will:

    • Merge hotfix branch into master branch.
    • TAG of the new version in master
    • Merge hotfix branch into develop branch
    • Delete release branch
  • Push changes to remote repository:

    git push origin main
    git push origin develop
    git push origin --tags
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment