rehannali

Git Model sourcetree

Mar 11th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

A successful Git branching model

Model

Main Branches

  • master
  • develop

Supporting brach

  • Release
  • Hotfix
  • Feature

Feature Branches

Feature branches are used to develop a new feature for an upcoming or distant future release.

Feature branches only exist in developers repos only i.e. in their machine, not in origin i.e. remote.

  • branch from develop
  • must be merged back in develop
  • Naming convention -> Anything except
    • master
    • develop
    • release-*
    • hotfix-*

Creating a feature branch

Creating Feature

After finishing the feature and merge back to develop

Compare

Sourcetree Version

SourceTree after finishing p1

p2

<strong style="color:red">Take pull before pushing your code if pull is available.</strong>

p3

It is impossible to see from git history of which commit objects together implement a feature. You would have to manually read all commit messages. If you need to revert particular feature, it is true headache in later situations, whereas it is easy with --no-ff flag was used.

It will create more empty commits but the gain is much bigger than cost.

Release Branches

  • Branch from develop
  • Must merge back in develop and master
  • Branch naming conventions
    • release-*

Creating release branch

Release1

You have to collect release notes from commit you can type one. Bump version to 1.2.1 as matches with your release branch name.

Finishing release branch

Finishing Release

To keep changes made by release branch, we need to merge in develop

Finishing off

This may lead to merge conflict. If so, fix and commit it.

Hotfix Branches

  • Branch from master
  • Must merge back in develop and master
  • Branch naming conventions
    • hotfix-*

Hotfix branches are very much like release branches in that they are meant to prepare for production, albeit unplanned. When a critical bug in production version must be resolved immediately, a hotfix branch may be branch of from corresponding tag on master branch that marks production version.

Hotfix Branch

Creating hotfix branch

Creating hotfix

Don't forget to bump a version after branching off.
Then fix the bug and commit changes

Finishing hotfix branch

When finished the bug fixed, we need to merge back in master as well as develop branch, in order to safeguard that the bug fix also include in next release as well.

Finishing Hotfix

The one exception rule is that, When a release branch currently exists, the hotfix branch need to be merge in release branch instead of develop. Back merging the bug fix into release branch eventually result in the hotfix branch merge in develop too, when release branch is finished. (If work in develop immediately require the hotfix and cannot wait it fo release branch to finish, you can safely merge in develop branch now already as well.)

Information

Information

You can find full documentation and explanation here. Feel free to check it out.

Other links to learn and embrace the power of Git.

  1. Git documentation
  2. Git tutorial
  3. Git dev docs
  4. Git tutorial and training
  5. Git power tools for daily use
Add Comment
Please, Sign In to add comment