Branching strategy

General Discussions
Post Reply
Mohammedaln
Posts: 10
Joined: Sat Nov 02, 2019 3:41 pm

Branching strategy

Post by Mohammedaln » Sun Jan 26, 2020 6:14 am

to control workflow of development team in development, releasing, hot fix and deployment of application by branches.
git-model@2x.png
git-model@2x.png (122 KiB) Viewed 102307 times
* The main branches
1. master
is the branch for production
2. develop
is the main branch for developing




* Supporting branches
these branches always have a limited life time, since they will be removed eventually.

1. Feature branches

May branch off from:
develop
Must merge back into:
develop
Branch naming convention:
anything except master, develop, release-*, or hotfix-*

- Creating a feature branch

Code: Select all

$ git checkout -b myfeature develop
Switched to a new branch "myfeature"
- Incorporating a finished feature on develop

Code: Select all

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop

2. Release branches
May branch off from:
develop
Must merge back into:
develop and master
Branch naming convention:
release-*

- Creating a release branch

Code: Select all

$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"
$ ./bump-version.sh 1.2
Files modified successfully, version bumped to 1.2.
$ git commit -a -m "Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)
- Finishing a release branch

Code: Select all

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
+ To keep the changes made in the release branch, we need to merge those back into develop, though. In Git:

Code: Select all

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
- remove the branch

Code: Select all

$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).
3. Hotfix branches
May branch off from:
master
Must merge back into:
develop and master
Branch naming convention:
hotfix-*


- Creating the hotfix branch

Code: Select all

$ git checkout -b hotfix-1.2.1 master
Switched to a new branch "hotfix-1.2.1"
$ ./bump-version.sh 1.2.1
Files modified successfully, version bumped to 1.2.1.
$ git commit -a -m "Bumped version number to 1.2.1"
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)
/*
Don’t forget to bump the version number after branching off!

Then, fix the bug and commit the fix in one or more separate commits.
*/
$ git commit -m "Fixed severe production problem"
- Finishing a hotfix branch

Code: Select all

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2.1
Next, include the bugfix in develop, too:

Code: Select all

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
Finally, remove the temporary branch:

Code: Select all

$ git branch -d hotfix-1.2.1
Deleted branch hotfix-1.2.1 (was abbe5d6). 




references
https://nvie.com/posts/a-successful-git ... ng-model/
https://git-scm.com/book/en/v2/Git-Bran ... -Workflows

Post Reply