eXoer on the grill: New Git Rebase Workflow

Preview:

Citation preview

Presentation of the new

GIT REBASEworkflow in eXo

Copyright 2014 eXo Platform

Why in eXo we stop using GIT MERGE and start using GIT REBASE to integrate change

from one branch to another

Copyright 2014 eXo Platform

A presentation

by Trong from Portal Team Copyright 2014 eXo Platform

Agenda

Copyright 2014 eXo Platform

Enjoy...

1. Git Merge Process2. Git Rebase Introduction3. Rebase - the new eXo Workflow4. Transition/Migration from Merge to Rebase

In eXo we used the

GIT MERGEmethod until today

Copyright 2014 eXo Platform

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

Consequences

Wonderful ???

Copyright 2014 eXo Platform

Amazing graph of commits history

Consequences

Copyright 2014 eXo Platform

Copyright 2014 eXo Platform

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

An introduction to the powerful

GIT REBASEmethod to integrate change

Copyright 2014 eXo Platform

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

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

How it works basicallyLet’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

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

Instantiate the new

WORKFLOWusing Git Rebase

Copyright 2014 eXo Platform

Common rules

● Never push --force in master

● Push --force is only allowed in FBs

● Be careful before pushing with --force

Copyright 2014 eXo Platform

Feature branch

Create a feature branch (FB) from masterC1---C2 (master)

\

C3 (FB)

with C3 is the POMs version update commit

Copyright 2014 eXo Platform

Feature branchAfter 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

Feature branchMerge 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

Good Practices

● Squash related commits before merging

● Plan to sync with master as frequently as possible (jenkin jobs ?)

Copyright 2014 eXo Platform

It’s time to

MIGRATEfrom merge to rebase

Copyright 2014 eXo Platform

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

You are interesting to

LEARN MOREabout our Git Workflow in eXo ?

Copyright 2014 eXo Platform

http://developer.exoplatform.org/docs/scm/git/workflow/

Recommended