Thursday, June 13, 2013

Git flow in action

Objective:

This is a gentle introduction to "git flow" using a hands-on example.

Introduction:

In an typical Agile/SCRUM shop, there are several teams constituting of developers and QA personnel who collaborate across several sprint lanes. Their primary objective is to deliver functional user stories at the end of each sprint cycle. In such an environment of rapid iterative development, it is essential to have a very well defined strategy to branch, merge, tag, release, patch the source code repository. This can become problematic real fast especially when using DVCS such as GIT. Here is where "Git Flow" comes into play.

Git Flow is both a methodology and software (underneath the covers runs git commands). It takes the best enterprise practices we are familiar with in a centralized version control system and applies them to GIT.

Here are 4 resources that I found really helpful while learning Git Flow.
  1. 2012 UTOSC - Using Git-Flow to Relieve Your Headaches - Tom Doggett
  2. Successful Git Branching Model - Vincent Driessen
  3. Git flow Cheat Sheet - Daniel Kummer
  4. Getting started with Git Flow
  5. Issues with Git Flow; Intro to GitHub Flow - Scott Chacon
Overview:

In this post, I'd like to share how two popular fictitious developers (Bob and Alice) use Git Flow to develop software collaboratively. Both have their own git repository and collaborate via central repository hosted on Github.

We will cover the following scenarios:
  1. Initializing Git Flow's recommended branching mechanism
  2. Developing "features"
  3. Release Management
  4. Hot Fixes

Prerequisites:

If you are reading about git flow, it is fair to assume that you are aware of basics of git and have used GitHub. There are lot of blogs that go over git basics and how to  install git and git flow. I'd suggest that you get a bit of  hands-on experience with git and GitHub before reading further as it will help you follow along much easily.

In this example, both Bob and Alice have read and write access to the same shared GitHub repository.

Deep Dive:

Initializing Git Flow's recommended branching mechanism

Bob begins by creating a repo in Github called "gitflow-example"



Now that Bob has an empty repo on Github, he creates a local Git repo using gitflow and sticks to the recommended branch naming convention suggested by Git Flow.


Ashwinis-MacBook-Pro:git akuntamukkala$ mkdir GitFlowExample
Ashwinis-MacBook-Pro:git akuntamukkala$ cd GitFlowExample/
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow init
Initialized empty Git repository in /Users/akuntamukkala/GIT/GitFlowExample/.git/
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch
* develop
  master
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ touch README.md
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ echo "this is to help understand use of git flow" > README.md
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git add .
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git commit -m "first commit"
[develop 4b88910] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git remote add origin git@github.com:akuntamukkala/gitflow-example.git
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push --all
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 430 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
 * [new branch]      develop -> develop
 * [new branch]      master -> master



Here is the screenshot of repository on Github showing both develop and master branches. Current active branch "develop"



Alice clones the gitflow-example.git repo from Github and initializes git flow on her local repository. She also sticks to the same branch naming convention recommended by Git Flow.



C:\GIT\GitFlowExample>git clone git@github.com:akuntamukkala/gitflow-example.git
Cloning into 'gitflow-example'...
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Receiving objects: 100% (5/5), done.

C:\GIT\GitFlowExample>cd gitflow-example

C:\GIT\GitFlowExample\gitflow-example>git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>git flow init
Which branch should be used for bringing forth production releases?
- master
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []

C:\GIT\GitFlowExample\gitflow-example>git branch -a
* develop
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>git branch -vv
* develop 4b88910 [origin/develop] first commit
master 078f615 [origin/master] Initial commit


C:\GIT\GitFlowExample\gitflow-example>dir
Volume in drive C has no label.
Volume Serial Number is 48D7-B5DC

Directory of C:\GIT\GitFlowExample\gitflow-example
04/24/2013 02:49 PM <DIR> .
04/24/2013 02:49 PM <DIR> ..
04/24/2013 02:49 PM 44 README.md
1 File(s) 44 bytes
2 Dir(s) 39,041,245,184 bytes free

C:\GIT\GitFlowExample\gitflow-example>type README.md
this is to help understand use of git flow


Developing "features" in isolation:

Let's say Alice is implementing a feature "xyz" by herself (not in collaboration)

The following commands creates a branch "feature/feature-xyz" off the "develop" branch.



C:\GIT\GitFlowExample\gitflow-example>git flow feature start feature-xyz
Switched to a new branch 'feature/feature-xyz'
Summary of actions:
- A new branch 'feature/feature-xyz' was created, based on 'develop'
- You are now on branch 'feature/feature-xyz'

Now, start committing on your feature. When done, use:
git flow feature finish feature-xyz

C:\GIT\GitFlowExample\gitflow-example>dir
Volume in drive C has no label.
Volume Serial Number is 48D7-B5DC Directory of C:\GIT\GitFlowExample\gitflow-example
04/24/2013 02:49 PM <DIR> .
04/24/2013 02:49 PM <DIR> ..
04/24/2013 02:49 PM 44 README.md
1 File(s) 44 bytes
2 Dir(s) 39,041,175,552 bytes free

C:\GIT\GitFlowExample\gitflow-example>git branch -vv
develop 4b88910 [origin/develop] first commit
* feature/feature-xyz 4b88910 first commit
master 078f615 [origin/master] Initial commit

Alice starts implementing the feature xyz...



C:\GIT\GitFlowExample\gitflow-example>echo "feature xyz implemented" > feature-xyz-impl.txt

C:\GIT\GitFlowExample\gitflow-example>echo "feature xyz adds cool capability" >> README.md

C:\GIT\GitFlowExample\gitflow-example>git add .

C:\GIT\GitFlowExample\gitflow-example>git commit -m "implemented feature-xyz"
[feature/feature-xyz 02d1a06] implemented feature-xyz
2 files changed, 2 insertions(+)
create mode 100644 feature-xyz-impl.txt


Now that Alice commits the newly implemented feature xyz  to her local repository, it is time for her to merge her changes to the "develop" branch and delete "feature/feature-xyz" branch.


C:\GIT\GitFlowExample\gitflow-example>git flow feature finish feature-xyz
Switched to branch 'develop'
Updating 4b88910..02d1a06
Fast-forward
README.md | 1 +
feature-xyz-impl.txt | 1 +
2 files changed, 2 insertions(+)
create mode 100644 feature-xyz-impl.txt
Deleted branch feature/feature-xyz (was 02d1a06).

Summary of actions:
- The feature branch 'feature/feature-xyz' was merged into 'develop'
- Feature branch 'feature/feature-xyz' has been removed
- You are now on branch 'develop'

C:\GIT\GitFlowExample\gitflow-example>git log --pretty=format:"%h %s" --graph * 02d1a06 implemented feature-xyz
* 4b88910 first commit
* 078f615 Initial commit


Alice pushes her changes from "develop" branch from local repository to the "develop" branch on central repository on GitHub.



C:\GIT\GitFlowExample\gitflow-example>git push
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 414 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
4b88910..02d1a06 develop -> develop


Now Bob wants to get the newly added feature xyz


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop 4b88910 first commit
master 078f615 Initial commit

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch --set-upstream develop origin/develop
Branch develop set up to track remote branch develop from origin.

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch --set-upstream master origin/master
Branch master set up to track remote branch master from origin.

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop 4b88910 [origin/develop: behind 1] first commit
master 078f615 [origin/master] Initial commit

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git pull
Updating 4b88910..02d1a06
Fast-forward
README.md | 1 +
feature-xyz-impl.txt | 1 +
2 files changed, 2 insertions(+)
create mode 100644 feature-xyz-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop 02d1a06 [origin/develop] implemented feature-xyz
master 078f615 [origin/master] Initial commit


Developing "features" in collaboration:


Say Bob and Alice now want to start developing a feature collaboratively.

Bob creates a new feature "abc"


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow feature start feature-abc
Switched to a new branch 'feature/feature-abc'
Summary of actions:

- A new branch 'feature/feature-abc' was created, based on 'develop'
- You are now on branch 'feature/feature-abc'
Now, start committing on your feature. When done, use:

git flow feature finish feature-abc

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow feature list
* feature-abc

Bob implements feature "abc", commits changes to local repo's feature/feature-abc branch.


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ touch feature-abc-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ echo "dev 1 implementing feature abc partially" > feature-abc-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git add .

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git commit -m "dev 1 - partial impl of feature-abc"
[feature/feature-abc c50551c] dev 1 - partial impl of feature-abc
1 file changed, 1 insertion(+)
create mode 100644 feature-abc-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push
Everything up-to-date

Bob now publishes feature-abc to repository on GitHub.


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow feature publish feature-abc
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 381 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
* [new branch] feature/feature-abc -> feature/feature-abc
Already on 'feature/feature-abc'
Summary of actions:
- A new remote branch 'feature/feature-abc' was created
- The local branch 'feature/feature-abc' was configured to track the remote branch
- You are now on branch 'feature/feature-abc'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
develop 02d1a06 [origin/develop] implemented feature-xyz
* feature/feature-abc c50551c [origin/feature/feature-abc] dev 1 - partial impl of feature-abc
master 078f615 [origin/master] Initial commit


Alice now attempts to pull the feature-abc published by Bob

C:\GIT\GitFlowExample\gitflow-example>git flow feature pull origin feature-abc
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Created local branch feature/feature-abc based on origin's feature/feature-abc.

C:\GIT\GitFlowExample\gitflow-example>git branch -a
develop
* feature/feature-abc
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/feature/feature-abc
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>dir
Volume in drive C has no label.
Volume Serial Number is 48D7-B5DC
Directory of C:\GIT\GitFlowExample\gitflow-example
04/24/2013 04:25 PM <DIR> .
04/24/2013 04:25 PM <DIR> ..
04/24/2013 04:25 PM 42 feature-abc-impl.txt
04/24/2013 03:04 PM 28 feature-xyz-impl.txt
04/24/2013 03:04 PM 81 README.md
3 File(s) 151 bytes
2 Dir(s) 38,988,984,320 bytes free

Alice continues to implement feature abc.


C:\GIT\GitFlowExample\gitflow-example>type feature-abc-impl.txt
dev 1 implementing feature abc partially

Alice finishes the implementation of feature "abc" and commits her changes to her local repository.


C:\GIT\GitFlowExample\gitflow-example>printf "\ndev2 completed implementation of feature abc" >> feature-abc-impl.txt

C:\GIT\GitFlowExample\gitflow-example>type feature-abc-impl.txt
dev 1 implementing feature abc partially
dev2 completed implementation of feature abc

C:\GIT\GitFlowExample\gitflow-example>git add .
warning: LF will be replaced by CRLF in feature-abc-impl.txt.
The file will have its original line endings in your working directory.

C:\GIT\GitFlowExample\gitflow-example>git commit -m "feature abc implementation completed by dev 2"
[feature/feature-abc warning: LF will be replaced by CRLF in feature-abc-impl.txt.
The file will have its original line endings in your working directory.
5671d9f] feature abc implementation completed by dev 2
warning: LF will be replaced by CRLF in feature-abc-impl.txt.
The file will have its original line endings in your working directory.
1 file changed, 3 insertions(+), 1 deletion(-)

C:\GIT\GitFlowExample\gitflow-example>git flow feature list
* feature-abc


Now that this new feature abc is completely implemented, Alice figures it is time to merge changes from "feature/feature-abc" branch to the "develop" branch of her local repository.

C:\GIT\GitFlowExample\gitflow-example>git flow feature finish feature-abc
Branches 'feature/feature-abc' and 'origin/feature/feature-abc' have diverged.
And local branch 'feature/feature-abc' is ahead of 'origin/feature/feature-abc'.
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
feature-abc-impl.txt | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 feature-abc-impl.txt
Deleted branch feature/feature-abc (was 5671d9f).

Summary of actions:
- The feature branch 'feature/feature-abc' was merged into 'develop'
- Feature branch 'feature/feature-abc' has been removed
- You are now on branch 'develop'

C:\GIT\GitFlowExample\gitflow-example>git branch -r
origin/HEAD -> origin/master
origin/develop
origin/feature/feature-abc
origin/master

C:\GIT\GitFlowExample\gitflow-example>git branch -a
* develop
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/feature/feature-abc
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 3 commits.
#
nothing to commit, working directory clean

Alice pushes changes from her local repository containing completed feature-abc implementation to the central repository on GitHub.


C:\GIT\GitFlowExample\gitflow-example>git push
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 573 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
02d1a06..fdef09a develop -> develop



It may be noted that "feature/feature-abc" branch has been deleted in Alice's local repository but still exists in Github repository. Alice deletes feature-abc branch from Github repo.

C:\GIT\GitFlowExample\gitflow-example>git branch -a
* develop
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/feature/feature-abc
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>git fetch origin feature/feature-abc
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
From github.com:akuntamukkala/gitflow-example
* branch feature/feature-abc -> FETCH_HEAD

C:\GIT\GitFlowExample\gitflow-example>git branch -vv
* develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit

C:\GIT\GitFlowExample\gitflow-example>git push origin :feature/feature-abc
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
To git@github.com:akuntamukkala/gitflow-example.git
- [deleted] feature/feature-abc


Bob updates local repo to get completely implemented feature "abc"


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -a
develop
* feature/feature-abc
master
remotes/origin/develop
remotes/origin/feature/feature-abc
remotes/origin/master

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git remote prune origin
Pruning origin
URL: git@github.com:akuntamukkala/gitflow-example.git
* [pruned] origin/feature/feature-abc

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
develop 02d1a06 [origin/develop: behind 3] implemented feature-xyz
* feature/feature-abc c50551c [origin/feature/feature-abc] dev 1 - partial impl of feature-abc
master 078f615 [origin/master] Initial commit


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git checkout develop
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 3 commits, and can be fast-forwarded.

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git pull
Updating 02d1a06..fdef09a
Fast-forward
feature-abc-impl.txt | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 feature-abc-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch
* develop
feature/feature-abc
master

Bob needs to delete feature/feature-abc branch from local repo because his local repository's "develop" branch already contains the merged feature abc implementation.

"git remote prune origin" command helps identify that remote branch (feature/feature-abc) that Bob was tracking has been deleted.


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -d feature/feature-abc
Deleted branch feature/feature-abc (was c50551c).

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit




Release Management:

Now let's talk about making a release as both features "xyz" and "abc" have been implemented and tested.

Bob is ready to cut a release, say release-1.0 :)

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow release start release-1.0
Switched to a new branch 'release/release-1.0'

Summary of actions:
- A new branch 'release/release-1.0' was created, based on 'develop'
- You are now on branch 'release/release-1.0'

Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

git flow release finish 'release-1.0'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit
* release/release-1.0 fdef09a Merge branch 'feature/feature-abc' into develop

Bob publishes the release-1.0 to remote repo so Alice may start tracking the release-1.0 branch


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow release publish release-1.0
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
* [new branch] release/release-1.0 -> release/release-1.0
Already on 'release/release-1.0'
Summary of actions:
- A new remote branch 'release/release-1.0' was created
- The local branch 'release/release-1.0' was configured to track the remote branch
- You are now on branch 'release/release-1.0'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit
* release/release-1.0 fdef09a [origin/release/release-1.0] Merge branch 'feature/feature-abc' into develop


Alice fetches the latest from remote repo and begins tracking release-1.0 branch


C:\GIT\GitFlowExample\gitflow-example>git fetch
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
From github.com:akuntamukkala/gitflow-example
* [new branch] release/release-1.0 -> origin/release/release-1.0

C:\GIT\GitFlowExample\gitflow-example>git branch -a
* develop
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master
remotes/origin/release/release-1.0

C:\GIT\GitFlowExample\gitflow-example>git branch -vv
* develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit

C:\GIT\GitFlowExample\gitflow-example>git flow release track release-1.0
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Branch release/release-1.0 set up to track remote branch release/release-1.0 from origin.
Switched to a new branch 'release/release-1.0'

Summary of actions:
- A new remote tracking branch 'release/release-1.0' was created
- You are now on branch 'release/release-1.0'

C:\GIT\GitFlowExample\gitflow-example>git branch -vv
develop fdef09a [origin/develop] Merge branch 'feature/feature-abc' into develop
master 078f615 [origin/master] Initial commit
* release/release-1.0 fdef09a [origin/release/release-1.0] Merge branch 'feature/feature-abc' into develop

Bob creates release notes for release-1.0 claiming the valuable addition of features abc and xyz

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git status -s

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ ls
README.md feature-abc-impl.txt feature-xyz-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ touch release-notes.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ echo this new release contains two new features abc and xyz > release-notes.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git status -s
?? release-notes.txt
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git add .

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git commit -m "release notes for release-1.0"
[release/release-1.0 15af591] release notes for release-1.0
1 file changed, 1 insertion(+)
create mode 100644 release-notes.txt
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 347 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
fdef09a..15af591 release/release-1.0 -> release/release-1.0

Now that the release has been deemed successful, Bob proceeds to finish release process.



Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow release finish release-1.0
Switched to branch 'master'
Merge made by the 'recursive' strategy.
README.md | 2 ++
feature-abc-impl.txt | 3 +++
feature-xyz-impl.txt | 1 +
release-notes.txt | 1 +
4 files changed, 7 insertions(+)
create mode 100644 README.md
create mode 100644 feature-abc-impl.txt
create mode 100644 feature-xyz-impl.txt
create mode 100644 release-notes.txt
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
release-notes.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 release-notes.txt
Deleted branch release/release-1.0 (was 15af591).

Summary of actions:
- Latest objects have been fetched from 'origin'
- Release branch has been merged into 'master'
- The release was tagged 'release-1.0'
- Release branch has been back-merged into 'develop'
- Release branch 'release/release-1.0' has been deleted

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git log --oneline --graph
* 8e36a5e Merge branch 'release/release-1.0' into develop
|\
| * 15af591 release notes for release-1.0
|/
* fdef09a Merge branch 'feature/feature-abc' into develop
|\
| * 5671d9f feature abc implementation completed by dev 2
| * c50551c dev 1 - partial impl of feature-abc
|/
* 02d1a06 implemented feature-xyz
* 4b88910 first commit
* 078f615 Initial commit

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop 8e36a5e [origin/develop: ahead 2] Merge branch 'release/release-1.0' into develop
master cde8e44 [origin/master: ahead 7] Merge branch 'release/release-1.0'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -a
* develop
master
remotes/origin/develop
remotes/origin/master
remotes/origin/release/release-1.0

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push origin :release/release-1.0
To git@github.com:akuntamukkala/gitflow-example.git
- [deleted] release/release-1.0
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git status -s

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 7 commits.

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 529 bytes, done.
Total 5 (delta 3), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
fdef09a..8e36a5e develop -> develop
078f615..cde8e44 master -> master

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git log --oneline --graph
* cde8e44 Merge branch 'release/release-1.0'
|\
| * 15af591 release notes for release-1.0
| * fdef09a Merge branch 'feature/feature-abc' into develop
| |\
| | * 5671d9f feature abc implementation completed by dev 2
| | * c50551c dev 1 - partial impl of feature-abc
| |/
| * 02d1a06 implemented feature-xyz
| * 4b88910 first commit
|/
* 078f615 Initial commit

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git checkout develop
Switched to branch 'develop'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git status
# On branch develop
nothing to commit (working directory clean)

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
* develop 8e36a5e [origin/develop] Merge branch 'release/release-1.0' into develop
master cde8e44 [origin/master] Merge branch 'release/release-1.0'

Alice updates local repo



C:\GIT\GitFlowExample\gitflow-example>git remote prune origin
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Pruning origin
URL: git@github.com:akuntamukkala/gitflow-example.git
* [pruned] origin/release/release-1.0

C:\GIT\GitFlowExample\gitflow-example>git checkout master
Switched to branch 'master'

C:\GIT\GitFlowExample\gitflow-example>git branch -a
develop
* master
release/release-1.0
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master

C:\GIT\GitFlowExample\gitflow-example>git pull
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
remote: Counting objects: 2, done.
remote: Total 2 (delta 1), reused 2 (delta 1)
Unpacking objects: 100% (2/2), done.
From github.com:akuntamukkala/gitflow-example
078f615..cde8e44 master -> origin/master
fdef09a..8e36a5e develop -> origin/develop
Updating 078f615..cde8e44
Fast-forward
README.md | 2 ++
feature-abc-impl.txt | 3 +++
feature-xyz-impl.txt | 1 +
release-notes.txt | 1 +
4 files changed, 7 insertions(+)
create mode 100644 README.md
create mode 100644 feature-abc-impl.txt
create mode 100644 feature-xyz-impl.txt
create mode 100644 release-notes.txt

C:\GIT\GitFlowExample\gitflow-example>git checkout develop
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 2 commits, and can be fast-forwarded.

C:\GIT\GitFlowExample\gitflow-example>git pull
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Updating fdef09a..8e36a5e
Fast-forward
release-notes.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 release-notes.txt

C:\GIT\GitFlowExample\gitflow-example>git branch -d release/release-1.0
Deleted branch release/release-1.0 (was 15af591).

Let's look at repo history on Bob's local repo


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ gitk --all

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -a
* develop
master
remotes/origin/develop
remotes/origin/master
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git tag
release-1.0


Hot Fix:

Let's say an urgent production issue has been discovered for which a fix needs to be made.

Bob makes a hotfix branch against master (which has the same code merged from release-1.0 branch)


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow hotfix start hotfix-1-release-1.0
Switched to a new branch 'hotfix/hotfix-1-release-1.0'

Summary of actions:
- A new branch 'hotfix/hotfix-1-release-1.0' was created, based on 'master'
- You are now on branch 'hotfix/hotfix-1-release-1.0'

Follow-up actions:
- Bump the version number now!
- Start committing your hot fixes
- When done, run:

git flow hotfix finish 'hotfix-1-release-1.0'



Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv
develop 8e36a5e [origin/develop] Merge branch 'release/release-1.0' into develop
* hotfix/hotfix-1-release-1.0 cde8e44 Merge branch 'release/release-1.0'
master cde8e44 [origin/master] Merge branch 'release/release-1.0'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ ls
README.md feature-abc-impl.txt feature-xyz-impl.txt release-notes.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ printf "\ncritical memory leak fix made to feature abc\n" >> feature-abc-impl.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ printf "\nhotfix #1 - memory leak issue fixed\n" >> release-notes.txt

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git add .


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git commit -m "critical hotfix#1 made"
[hotfix/hotfix-1-release-1.0 3d8b4ec] critical hotfix#1 made
2 files changed, 4 insertions(+), 1 deletion(-)


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ gitk --all



Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git flow hotfix finish hotfix-1-release-1.0
Switched to branch 'master'
Merge made by the 'recursive' strategy.
feature-abc-impl.txt | 3 ++-
release-notes.txt | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
feature-abc-impl.txt | 3 ++-
release-notes.txt | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
Deleted branch hotfix/hotfix-1-release-1.0 (was 3d8b4ec).

Summary of actions:
- Latest objects have been fetched from 'origin'
- Hotfix branch has been merged into 'master'
- The hotfix was tagged 'hotfix-1-release-1.0'
- Hotfix branch has been back-merged into 'develop'
- Hotfix branch 'hotfix/hotfix-1-release-1.0' has been deleted



Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ gitk --all



Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git branch -vv

* develop 5a7edd4 [origin/develop: ahead 3] Memory leak issue Merge branch 'hotfix/hotfix-1-release-1.0' into develop
master 4a9a0e3 [origin/master: ahead 2] Merge branch 'hotfix/hotfix-1-release-1.0'

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git tag -n

hotfix-1-release-1.0 fixed memory leak issue
release-1.0 tag for release-1.0 : introducing features abc and xyz

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git fetch origin develop

From github.com:akuntamukkala/gitflow-example
* branch develop -> FETCH_HEAD

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git fetch origin master

From github.com:akuntamukkala/gitflow-example
* branch master -> FETCH_HEAD

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git diff origin/develop develop

diff --git a/feature-abc-impl.txt b/feature-abc-impl.txt
index c1421c6..0cdb22a 100644
--- a/feature-abc-impl.txt
+++ b/feature-abc-impl.txt
@@ -1,3 +1,4 @@
dev 1 implementing feature abc partially


-dev2 completed implementation of feature abc

\ No newline at end of file
+dev2 completed implementation of feature abc
+critical memory leak fix made to feature abc
diff --git a/release-notes.txt b/release-notes.txt
index 0a0b518..6f3c3ff 100644
--- a/release-notes.txt
+++ b/release-notes.txt
@@ -1 +1,3 @@
this new release contains two new features abc and xyz
+
+hotfix #1 - memory leak issue fixed


Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 2 commits.

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git diff origin/master master

diff --git a/feature-abc-impl.txt b/feature-abc-impl.txt
index c1421c6..0cdb22a 100644
--- a/feature-abc-impl.txt
+++ b/feature-abc-impl.txt
@@ -1,3 +1,4 @@
dev 1 implementing feature abc partially

-dev2 completed implementation of feature abc

\ No newline at end of file
+dev2 completed implementation of feature abc
+critical memory leak fix made to feature abc
diff --git a/release-notes.txt b/release-notes.txt
index 0a0b518..6f3c3ff 100644
--- a/release-notes.txt
+++ b/release-notes.txt
@@ -1 +1,3 @@
this new release contains two new features abc and xyz
+
+hotfix #1 - memory leak issue fixed

Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push origin --all

Counting objects: 9, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 674 bytes, done.
Total 6 (delta 3), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
8e36a5e..5a7edd4 develop -> develop
cde8e44..4a9a0e3 master -> master
Ashwinis-MacBook-Pro:GitFlowExample akuntamukkala$ git push origin --tags
Counting objects: 2, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 350 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@github.com:akuntamukkala/gitflow-example.git
* [new tag] hotfix-1-release-1.0 -> hotfix-1-release-1.0
* [new tag] release-1.0 -> release-1.0


Alice updates her local repo from remote repo on Github which contains the hotfix #1 merged into "develop" and "master" branches along with "release-1.0" and "hotfix-1-release-1.0" tags

C:\GIT\GitFlowExample\gitflow-example>git remote update
Fetching origin
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (5/5), done.
Unpacking objects: 100% (8/8), done.
remote: Total 8 (delta 3), reused 8 (delta 3)
From github.com:akuntamukkala/gitflow-example
8e36a5e..5a7edd4 develop -> origin/develop
cde8e44..4a9a0e3 master -> origin/master
* [new tag] release-1.0 -> release-1.0
From github.com:akuntamukkala/gitflow-example
* [new tag] hotfix-1-release-1.0 -> hotfix-1-release-1.0

C:\GIT\GitFlowExample\gitflow-example>git diff develop origin/develop
diff --git a/feature-abc-impl.txt b/feature-abc-impl.txt
index c1421c6..0cdb22a 100644
--- a/feature-abc-impl.txt
+++ b/feature-abc-impl.txt
@@ -1,3 +1,4 @@
dev 1 implementing feature abc partially

-dev2 completed implementation of feature abc
\ No newline at end of file
+dev2 completed implementation of feature abc
+critical memory leak fix made to feature abc
diff --git a/release-notes.txt b/release-notes.txt
index 0a0b518..6f3c3ff 100644
--- a/release-notes.txt
+++ b/release-notes.txt
@@ -1 +1,3 @@
this new release contains two new features abc and xyz
+
+hotfix #1 - memory leak issue fixed

C:\GIT\GitFlowExample\gitflow-example>git diff master origin/master
diff --git a/feature-abc-impl.txt b/feature-abc-impl.txt
index c1421c6..0cdb22a 100644
--- a/feature-abc-impl.txt
+++ b/feature-abc-impl.txt
@@ -1,3 +1,4 @@
dev 1 implementing feature abc partially

-dev2 completed implementation of feature abc
\ No newline at end of file
+dev2 completed implementation of feature abc
+critical memory leak fix made to feature abc
diff --git a/release-notes.txt b/release-notes.txt
index 0a0b518..6f3c3ff 100644
--- a/release-notes.txt
+++ b/release-notes.txt
@@ -1 +1,3 @@
this new release contains two new features abc and xyz
+
+hotfix #1 - memory leak issue fixed

C:\GIT\GitFlowExample\gitflow-example>git tag -n
hotfix-1-release-1.0 fixed memory leak issue
release-1.0 tag for release-1.0 : introducing features abc and xyz

Alice pulls in the changes made to origin/master and origin/develop into her local repository


C:\GIT\GitFlowExample\gitflow-example>git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.

C:\GIT\GitFlowExample\gitflow-example>git pull

Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Updating cde8e44..4a9a0e3
Fast-forward
feature-abc-impl.txt | 3 ++-
release-notes.txt | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)


C:\GIT\GitFlowExample\gitflow-example>git checkout develop
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 3 commits, and can be fast-forwarded.

C:\GIT\GitFlowExample\gitflow-example>git pull
Enter passphrase for key '/c/Users/akuntamu/.ssh/id_rsa':
Updating 8e36a5e..5a7edd4
Fast-forward
feature-abc-impl.txt | 3 ++-
release-notes.txt | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
C:\GIT\GitFlowExample\gitflow-example>gitk --all



Conclusion:

In this blog we have explored a quick hands on introduction to git flow in order to do the following:


  1. Initializing Git Flow's recommended branching mechanism
  2. Developing "features"
  3. Working In isolation (developer implements by self)
  4. Working collaboratively via common repository on GitHub
  5. Release Management
  6. HotFixes

I hope that you found this helpful. I am constantly looking for ways to improve my proficiency in git and git flow. If you find something that can be improved, please don't hesitate to drop in a comment.

Thanks again for reading and making it this far ;)

No comments:

Post a Comment