Managing releases effectively through git
-
Upload
mohd-farid -
Category
Software
-
view
130 -
download
0
description
Transcript of Managing releases effectively through git
![Page 1: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/1.jpg)
Managing releases effectively through Git
- By Mohd Farid
![Page 2: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/2.jpg)
Agenda
● Git branching support
● Why branching strategy?
● Introducing git-flow
● Different branches for different purposes
● Different Workfows while using git-flow
![Page 3: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/3.jpg)
Git branching support
● Git allows us to create multiple branches.
● Merge any branch into another.
● Pull changes from any branch to any branch.
Note: With great power comes great responsibilities
![Page 4: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/4.jpg)
Why do I need a branching strategy?
![Page 5: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/5.jpg)
Git branching strategy - Why it is important ?
Frequent overwriting of my commits by this guy.
![Page 6: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/6.jpg)
Git branching strategy - Why it is important ?
Difficult to debug what went wrong from the clumsy tree structure.
![Page 7: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/7.jpg)
Git branching strategy - Why it is important ?
Situation goes out of control: We call the experts … and they do things like..
git reset HEAD git reset HARD and .. evil
Our hearts start beating faster and faster… with eachcommand they type !!!
![Page 8: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/8.jpg)
Git branching strategy - Why it is important ?
We always have a stable branch ready to be deployed to production.
![Page 9: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/9.jpg)
But before we solve it, lets see, how things go wrong…
The good, The bad and the ugly
![Page 10: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/10.jpg)
The Good - Single developer days
![Page 11: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/11.jpg)
The Bad - Two developers on the project
![Page 12: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/12.jpg)
The Ugly - Multiple developer days..
It definitely needs a genius (+ time) to decipher this tree.
![Page 13: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/13.jpg)
What is the way out from this ….. life ?
![Page 14: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/14.jpg)
Lets meet a branching strategy.. Git-flow
Git-flow is a way to manage our code such that:
● There are no code overrides by my colleague.
● If something goes wrong, I can easily figure out which commit failed by referring to a very simple tree.
![Page 15: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/15.jpg)
Lets meet a branching strategy.. Git-flow
Ques: Do I need to learn new set of commands for this
Ans: NO, We just need to be follow a simple process and everything will fall in place.
![Page 16: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/16.jpg)
Most frequently used commands
git pull origin development
git checkout -b branchName
git commit -am “Commit message”
git merge --no-ff feature-branch
git rebase
git branch -d
git push origin development
![Page 17: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/17.jpg)
What is git-flow
![Page 18: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/18.jpg)
What are these different kind of branches
● development branch
● feature branch
● release branch
● master branch
● hotfix branch
![Page 19: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/19.jpg)
Branches
![Page 20: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/20.jpg)
Merging a feature branch into development
1. git checkout development
2. git checkout -b JIRA-103
3. work on the feature.
4. commit your changes to the branch.
5. git checkout development
6. git pull origin development
7. if no new changes are received in the pull
8. git merge --no-ff JIRA-103
9. git push origin development
10. git branch -d JIRA-103
![Page 21: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/21.jpg)
Merging a feature branch into development
1. ….
2. if some new changes are received in the pull
3. git checkout JIRA-103
4. git rebase development // Rebasing the current branch (JIRA-
103) with development
5. git checkout development
6. git merge --no-ff JIRA-103
7. git push origin development
8. git branch -d JIRA-103
![Page 22: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/22.jpg)
Work flow 1: Working on a feature
1. git checkout development
2. git checkout -b JIRA-103
3. work on the feature.
4. commit your changes to the branch.
5. git checkout development
6. git pull origin development
7. if there are no new changes recieved in the pull
8. git merge --no-ff JIRA-103
9. git push origin development
![Page 23: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/23.jpg)
Work flow 1: Working on a feature
1. ...
2. git checkout development
3. git pull origin development
4. if there are some new changes received in the pull
5. git checkout JIRA-103
6. git rebase development
7. git checkout development
8. git merge --no-ff JIRA-103
9. git push origin development
![Page 24: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/24.jpg)
Workflow 2: Releasing to production
1. git checkout development
2. git checkout -b release-2.1
3. up the application version and commit this change.
4. git push origin release-2.1
5. test the release branch on staging environment
6. if there are any issues, fix them only on release branch
7. once satisfied, git checkout master
8. git merge --no-ff release-2.1
9. git tag v2.1
10. git push origin master
![Page 25: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/25.jpg)
Workflow 2: Releasing to production
...
once satisfied with release-2.1
git checkout master
git merge --no-ff release-2.1
git tag v2.1
git push origin master
git push --tags
deploy the master branch to production.
![Page 26: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/26.jpg)
Workflow 3: Addressing the Production issues: Hotfix branch
Once the master has been deployed to production and there is some issue on production.
1. git checkout master
2. git checkout -b hot-fix-2.1.1
3. increase the application version.
4. fix the issue and commit the changes.
Merge the hotfix branch on master & development *(if there is no active release branch. If there is one then merge it on master and the active release branch. )
![Page 27: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/27.jpg)
Workflow 3: Addressing the Production issues: Hotfix branch
Merging the hotfix branch on master..
1. git checkout master
2. git pull origin master
3. if there are no new changes:
4. git merge --no-ff hotfix-2.1.1
5. git push origin master
6. git branch -d hotfix-2.1.1
if there are changes in master then rebase the hotfix and then merge
![Page 28: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/28.jpg)
Workflow 3: Addressing the Production issues: Hotfix branch
Merging the hotfix branch on development..
1. git checkout development
2. git pull origin development
3. if there are no new changes:
4. git merge --no-ff hotfix-2.1.1
5. git push origin development
6. git branch -d hotfix-2.1.1
if there are changes in development then rebase the hotfix and then merge
![Page 29: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/29.jpg)
Few rules that worked for us..
● Never pull on one branch from another. In order to get those changes,
we do a rebase.
● Delete the feature branches, release branches and hotfix branches
once they are merged into the desired branch/es
● Never commit again on a branch which has already been merged into
the destination branch.
● Use feature branch names like ticket numbers, they help in quickly
identifying the purpose of the branch.
![Page 30: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/30.jpg)
Must read..
http://nvie.com/posts/a-successful-git-branching-model/
![Page 31: Managing releases effectively through git](https://reader035.fdocuments.in/reader035/viewer/2022062617/54b74f0f4a79592b5b8b4591/html5/thumbnails/31.jpg)
Questions