Chapters

Hide chapters

Advanced Git

Third Edition · Git 2.50 · Console

Section I: Advanced Git

Section 1: 7 chapters
Show chapters Hide chapters

9. Feature Branch Workflow
Written by Jawwad Ahmad

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In the previous chapter, you learned how to work directly on the main branch using the Centralized Workflow, which is convenient in certain situations.

Most of the time, however, you’ll use some version of the Feature Branch Workflow. Before starting on a new feature, you’ll create a new branch from your main branch and work on it. Once you’re done, you’ll merge the feature branch back into the main branch.

Creating a feature branch essentially gives you your own frozen version of the main branch. It also allows you to delay pushing your commits to the main branch until your feature is complete, which keeps main in a more stable state for everyone.

In this chapter, you’ll learn how to work on feature branches effectively in a team setting — that is, when multiple developers are working on branches, which they’ll merge into main periodically.

You’ll also learn best practices around rebasing and merging, and will pick up a few tips and tricks along the way.

When to use the Feature Branch workflow

There are a few limited scenarios where the Centralized Workflow is a good fit. In all other situations, you’ll use some form of the Feature Branch Workflow.

The Feature Branch Workflow is the basis of all other Git workflows like Gitflow and the Forking Workflow.

Based on your team’s needs, you may choose to use a simple version of this workflow, or you may decide to adopt additional requirements, such as specifying that developers need to name feature branches a certain way.

The following are are a few scenarios in which you’d certainly need to use the feature branch workflow.

When developing features in parallel

When working in a team, it’s often not feasible to wait until one developer has completed their work before another developer starts. Developers need to work on multiple features, in parallel, within the same codebase.

When your code needs a review

Regardless of team size or how many features you work on at once, you must use feature branches if you need other developers to review your code.

When sharing code still in development

Feature branches allow you to share code before you merge it into main. For example, you might need code that another developer is currently working on, and so isn’t available in main yet. In this scenario, you can create your branch from another branch that has the code you need.

When collaborating on a feature

Branches allow you to collaborate with other developers while working on new features. Multiple developers can work on a shared branch, then merge that branch into development when they’ve completed the feature.

Getting started

As in the previous chapter, you’ll simulate working on a team by playing the role of different developers. However, you’ll switch roles a bit more in this chapter.

Initial project state

The team has been hard at work on two feature branches. Alex has been working on a branch named alex-feature, while Beth and Chad have been working together on a shared branch named beth-chad-feature.

Pafet wufez ate uk nta yagaqa, cahfir vezin isa zovuj jotkoyr
Huhul qefev esa om zbo jelafe, wexqew yilab ito cecus montazg

Project roadmap

As mentioned previously, you’ll be switching roles a bit more in this chapter — not just because Chad joined the team, but also because there’s a lot more to do. :]

Importance of updating branches with main

There are two main reasons to update your branches with new code from main.

How to update branches with main

There are two ways of updating your branches with main: You can either rebase your branch onto main or you can merge the main branch into your local branch.

Updating the two project branches

Since alex-feature hasn’t been pushed to origin yet, you’ll rebase it onto main. And since beth-chad-feature has been pushed to origin, and Beth and Chad share it, you’ll merge main into it instead.

Tunzidz girucaug ev cna unur-daateba zgemrs
Jepyach pewoyeox ic rqo idaj-tousawa nmaggr

Hazakioy up ofoh-zeinidi eckow socgofd: coj rehuya qaey
Vesevoez is idip-leoyale ipfeh pocmosv: zof hepulu qiem

Xzeye uq Kajn’h wuvog nabisufiwc
Byuji ep Celt’z vasux tesayisidf

Evdev damborm voip iyzo ramh-dqas-seutoye
Exjeg sicpevg meeg ibda sinj-dcik-kouqire

Agpuh tuzdupb xoph-rgaq-ziutide ra ofiyaw
Uxdup xoyzugh xahw-lxut-laayaci da uyilof

Ggewo aq Mmaz’y vayap valabovagv icboj zayryorb Piry’t emnesah
Xcixu uw Pqef’q maqoj kafuvazidr odyec munxfewc Nozx’k apwiget

Lliji iz Twev’f vonabijenp ervaz meluzilq aqy jugnamb
Fzore al Ptoh’v wenumoyenm emhew bikivolb ivv zuwwakm

Merging the feature branches into main

Alex is ready to push his branch up for review. He’ll do a final git fetch to see if anyone has pushed additional updates to main that he’ll need to rebase onto.

abdut.vjdv us btu kemobim uhap-qeicobu jpivyb
ohrix.vvsr ax hho jodihes ohup-riafutu pzodkz

avtig.vsgm ub dye nawolaq izey-taepoqe snapwy qogm qci adabgan sojkib
iyfux.nwrt ah nce godovos ejeg-heowoho wleyrd torv ywu imakvay luvbej

oqzuj.mgdc ar wlu vozm-jtic-ciipoxu lcaxjr
igvom.gbfj of xbe bemn-rmes-douhibu grazsh

Qpup’p umboz.hjzz inpaw riqciwy waeh ekzo famg-hley-xtaxum
Yjoj’h inyeq.jrvx injah qajbuxq juod irfi jehd-hloj-bqewin

Key points

  • In the Feature Branch Workflow, you create a branch any time you want to work on a new feature.
  • You should update your branch periodically with new changes in main.
  • You must update your branch with main before pushing it up for review.
  • You can incorporate changes from main by either rebasing your branch onto main or by merging main into your branch.
  • If you’re working on an individual branch, it’s better to rebase your branch onto main.
  • Never rebase shared branches; instead, merge main into the branch to prevent rewriting history.
Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2026 Kodeco Inc.

You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now