www.exoplatform.com - Why at eXo we stop using Git Merge and start using Git Rebase to integrate change from one branch to another.
By Trong from eXo Portal Team
eXoers on the Grill aims to provide some incentive & fresh air for our staff in order to constantly re-think our methods, spread good practices, promote some technology or tools, generate ideas, etc... All the teams are invited to contribute by picking up some hot topics of their choice and spread to other teams.
4. Agenda
Copyright 2014 eXo Platform
Enjoy...
1. Git Merge Process
2. Git Rebase Introduction
3. Rebase - the new eXo Workflow
4. Transition/Migration from Merge to Rebase
5. In eXo we used the
GIT MERGE
method until today
Copyright 2014 eXo Platform
6. Process used today
● Using GIT-Merge for integrating changes between
branches
● Many feature branches are in progress in parallels
● Merge/Sync feature branches with master frequently,
every week(s) regularly
Copyright 2014 eXo Platform
10. Drawbacks
● Commit history is unusable for commit tracker
● Be off the track of Feature Branch development
● Potentially have to reset useless changes
● Don’t have a clear context when resolving conflicts ->
easy to make mistakes.
Copyright 2014 eXo Platform
11. An introduction to the powerful
GIT REBASE
method to integrate change
Copyright 2014 eXo Platform
12. Introduction
● Another way (beside Merge) to integrate changes
from one branch to another
● Take all the changes (commits) that were committed
on one branch and replay them on another one, one
by one in turn.
Copyright 2014 eXo Platform
13. Introduction
● Powerful tool to clean-up/re-organize commit
history
● A fast-forward merge to the branch you are rebasing
onto.
Copyright 2014 eXo Platform
14. How it works basically
Let’s say we have:
C1---C2---C6---C7 (master)
C3---C4---C5 (feature branch)
After rebase:
C1---C2---C6---C7 (master)
C3’---C4’---C5’ (feature branch)
Copyright 2014 eXo Platform
15. How smart
Let’s say C4 and C6 are exactly the same patch, like below:
C1---C2---C6---C7 (master)
C3---C4---C5 (stabilization)
After rebase:
C1---C2---C6---C7 (master)
C3’---C5’ (stabilization)
Copyright 2014 eXo Platform
17. Common rules
● Never push --force in master
● Push --force is only allowed in FBs
● Be careful before pushing with --force
Copyright 2014 eXo Platform
18. Feature branch
Create a feature branch (FB) from master
C1---C2 (master)
C3 (FB)
with C3 is the POMs version update commit
Copyright 2014 eXo Platform
19. Feature branch
After a long while, the history looks like:
C1---C2---C6---C7 (master)
C3---C4---C5 (feature branch)
Integrate changes from master with rebase:
C1---C2---C6---C7 (master)
C3’---C4’---C5’ (feature branch)
Copyright 2014 eXo Platform
20. Feature branch
Merge to master with non-fast-forward :
C1---C2---C6---C7-----------------C8 (master)
/
C3’---C4’---C5’ (feature branch)
Merge to master with fast-forward :
C1---C2---C6---C7---C4’---C5’ (master)
C4’---C5’ (feature branch)
Copyright 2014 eXo Platform
21. Good Practices
● Squash related commits before merging
● Plan to sync with master as frequently as possible
(jenkin jobs ?)
Copyright 2014 eXo Platform
23. Transition - Migration
● Start using rebase for new feature branch
● If possible, convert to use rebase on existing feature
branches
● Use rebase for auto-merge Jenkins jobs, such as
translation injection, etc. ???
● PORTAL team can be in charge of the migration
Copyright 2014 eXo Platform
24. You are interesting to
LEARN MORE
about our Git Workflow in eXo ?
Copyright 2014 eXo Platform
http://developer.exoplatform.org/docs/scm/git/workflow/