0% found this document useful (0 votes)
3 views29 pages

Gitflow Implementation

The document provides a comprehensive guide on the Gitflow branching model, detailing its introduction, implementation, and various branch types including feature, release, hotfix, and bugfix branches. It includes step-by-step instructions for initializing Gitflow, creating and merging branches, and managing configurations. The guide emphasizes minimizing human error and ensuring collaboration among developers during the development process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views29 pages

Gitflow Implementation

The document provides a comprehensive guide on the Gitflow branching model, detailing its introduction, implementation, and various branch types including feature, release, hotfix, and bugfix branches. It includes step-by-step instructions for initializing Gitflow, creating and merging branches, and managing configurations. The guide emphasizes minimizing human error and ensuring collaboration among developers during the development process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Contents

1. Gitflow Introdcution ............................................................................................................................. 2


1.1 GIT Branching Diagram ........................................................................................................... 2
2. GIT Flow Implementation .................................................................................................................... 3
2.1 GIT Flow Initial configuration ...................................................................................................... 3
2.2.1 git initialization ............................................................................................................................ 3
2.2.2 git flow-config verification .......................................................................................................... 4
2.2.3 Modifying/updating git flow config ............................................................................................. 5
2.2.4 post setup (Changing production as Default branch) ................................................................... 5
2.2 Creating Feature Branch ............................................................................................................... 7
2.2.1 git flow initial config for feature .................................................................................................. 7
2.2.2 Feature without using git flow ..................................................................................................... 8
2.2.3 Creating sub-branches for developer from feature-branch .......................................................... 8
2.2.4 Finalizing Merge of feature-branch ............................................................................................. 9
2.3 Creating Release branches .......................................................................................................... 13
2.3.1 Initializing Release branch using git flow ................................................................................. 13
2.3.2 Finalizing Release branch using Gitlow .................................................................................... 14
2.3.3 pushing release tag on github ..................................................................................................... 16
2.4 Creating release:................................................................................................................................ 18
2.4.1 Final Release .............................................................................................................................. 18
2.4 Hotfix branches ................................................................................................................................. 19
2.4.1 hotfix using git flow ................................................................................................................... 19
2.4.2 hotfix without git flow ............................................................................................................... 20
2.4.3 fixing and updating hotfix branch .............................................................................................. 20
2.4.4 hotfix to production and development ....................................................................................... 21
2.5 bugfix branches ........................................................................................................................... 26
2.5.1 bugfix initialization .................................................................................................................... 26
2.5.2 Developer will perform changes and push to bugfix branches .................................................. 26
2.5.3 finalizing the changes................................................................................................................. 28
1. Gitflow Introdcution
Gitflow is an alternative Git branching model that involves the use of feature branches and multiple primary
branches. It was first published and made popular by Vincent Driessen at nvie. Compared to trunk-based
development, Gitflow has numerous, longer-lived branches and larger commits. Under this model,
developers create a feature branch and delay merging it to the main trunk branch until the feature is
complete. These long-lived feature branches require more collaboration to merge and have a higher risk of
deviating from the trunk branch. They can also introduce conflicting updates.
1.0 Reference : https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
2.0 Reference : https://danielkummer.github.io/git-flow-cheatsheet/

1.1 GIT Branching Diagram


2. GIT Flow Implementation
2.1 GIT Flow Initial configuration
2.2.1 git initialization
Commands :
git branch production
git branch develop
git branch staging
git flow init
IF you already had initialized but want to change the branch for production and Staging
git flow init -f
Picture: creating branch before initializing git flow

Note : since production releases and next releases at least this 2 branch are required to setup git flow.
Initializing git flow
2.2.2 git flow-config verification
git flow config
git flow config list

Then upload all config to github


git push --all
2.2.3 Modifying/updating git flow config
Changing git-flow or forcefully init
git flow init -f

2.2.4 post setup (Changing production as Default branch)


Change production as default branch
Branch deletion and force push deny ruleset
2.2 Creating Feature Branch
2.2.1 git flow initial config for feature
Since git flow,
git flow tools create feature from development release i.e. (develop branch in my configuration). Even
though we are currently working on any branches. Hence it minimizes human error.
git flow feature start 0.0.1-banner-create
git flow feature publish 0.0.1-banner-create

Verifying on github

Then it should be available to all user after all develop has completed their changes
git pull origin
git flow feature finish 0.0.1/banner-create
2.2.2 Feature without using git flow
If we are not using git flow performing manually then perform. Manually goto develop branch and then
create branch from it. After performing all tasks need to merge manually
git checkout develop
git checkout -b feature_branch
git add .
git commit -m "adding inital code/task of application banner"
git checkout develop
git merge feature_branch

2.2.3 Creating sub-branches for developer from feature-branch


Since we will now create sub-branches from feature branches where developer performs changes and
merge to the feature branches.
git clone <reponame>
cd <repo-dir>
git branch feature-branch-xxx
git checkout feature-branch-xxx
git pull origin feature-branch-xxx
git branch subash-feature-branch
git checkout subash-feature-branch
git add .
git commit -m “final code commit”
git push -u origin

Step -1 : Creating own branch from feature-branch


Step -2 : Adding changes and pushing to repository

Verifying on github

Step -3 after-completing final rebase repo and create PR

2.2.4 Finalizing Merge of feature-branch


Verify updated of PR into feature branches
git checkout feature-0.0.1-banner-create
If you are already in feature-0.0.1-banner-create then perform
git pull origin
git flow feature finish 0.0.1-banner-create
git push --set-upstream origin develop
During merge: please write a respective message

Note : since, feature branch will be merged so it will be not show locally and remotely
But changes is also not reflected on develop branches due to it doesn’t push the changes on develop
branch you had to push it manually

Pushing changes into develop branches


git push --set-upstream origin develop
Verifying on github
2.3 Creating Release branches
2.3.1 Initializing Release branch using git flow
When using release branches, they are created from the develop branch. Once all changes are committed,
the release branch is finished, and using Git Flow, it is merged into both the main (production) and
develop branches. Human errors can be minimized.
git flow release start 0.1.0-banner-create
git flow release publish 0.1.0-banner-create
git add .
git commit -m "adding -descriptions of these release contains"
git flow release finish agentcis-ver-0.1.0
git push -u origin
git checkout production
git push --set-upstream origin production
creating and publishing release-branches
Verifying on github

2.3.2 Finalizing Release branch using Gitlow


Finalizing the config and merging to production
git flow release finish 0.1.0-banner-create

Message for production (1st message)


Also writing message for tag (2nd message)

Message for develop (3rd message)


There will be no any releases and nor any releases branches but changes will be not found on production
branches,

Step -2 : pushing changes to production


git checkout production
git push --set-upstream origin production

Verifying on github

2.3.3 pushing release tag on github


Note since: it still doesn’t contain any release, since we have to push the tag which are created during
commit of release branches.
to find the releases verify and push the tags
git tag
git push –tags

Finding releases of tags

Listing all tags


2.4 Creating release:
Similarly we can puh multiple tags and after final testing multiple times after a final successful
deployments having no issue create a final release.

2.4.1 Final Release


2.4 Hotfix branches
Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot
like release branches and feature branches except they're based on main instead of develop. As soon as the
fix is complete, it should be merged into both main and develop (or the current release branch), and main
should be tagged with an updated version number.
Note : Hotfix branch is created from main/production branch

2.4.1 hotfix using git flow


git flow hotfix start banner-display
git flow hotfix publish banner-display

Verifying branch into github repository


2.4.2 hotfix without git flow
git checkout main
git merge hotfix_branch
git checkout develop
git merge hotfix_branch
git branch -D hotfix_branch
2.4.3 fixing and updating hotfix branch
Making changes to fix issue arises on production by help of hotfix branches by try respective team members
git clone <repo>
cd <git-repo>
git branch <hotfix-branch>
git checkout <hotfix-branch>
git pull origin <hotfix-branch>
perform changes and then commit rebase and push
git add .
git commit -m “fixing production issue”
git push --set-upstream origin <hotfix-branches>
step -1 Pulling remote branches into local

Step -2 : after fixing pushing it to remotely


Now, verifying in github

2.4.4 hotfix to production and development


After developer or respective team dones changes for fix then, perform the following operations
git checkout hotfix-banner-display
git pull origin hotfix-banner-display
git flow hotfix finish banner-display
During finish config, It will ask for commit messages,
commit message for production (1st )

commit message for tag (2nd )


commit message for develop/staging (3rd )

Step-2 verifying on github


Since, branch will be merged to both production and develop and deleted from both locally and remotely.
But the changes will not found in both production and develop branches.
Production branches:
develop branches

Pushing changes to both branch, you can push individual branches instead of all
git push –all
git push –tags

Production branches
develop branches

Tags
2.5 bugfix branches
2.5.1 bugfix initialization
git flow bugfix start application-loading-issue
git flow bugfix publish application-loading-issue

Verifying in github repository

2.5.2 Developer will perform changes and push to bugfix branches


git clone <repo>
cd <git-repo>
git branch <bugfix-branch>
git checkout <bugfix-branch>
git pull origin <bugfix-branch>
git branch subash-<bugfix-branch>
git checkout subash-< bugfix-branch >
git add .
git commit -m “fixing production issue”
git push --set-upstream origin <bugfix-branches>
2.5.3 finalizing the changes

Pushing tags

Verifying on github

You might also like