Chapters

Hide chapters

Advanced Git

First Edition · Git 2.28 · 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 master 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 branch from master and work on it. Once you’re done, you’ll merge the feature branch back into master.

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

In previous chapters, you learned how to create branches, rebase branches, resolve conflicts and merge your branches back into master.

In this chapter, you’ll learn how to use these techniques effectively in a team setting — that is, when multiple developers are working on branches, which they’ll merge into master 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 or use a specific prefix with them.

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 master. For example, you might need code that another developer is currently working on, and so isn’t available in master 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 alex-feature, while Beth and Chad have been working together on a shared branch named beth-chad-feature.

Gobok dezec ato ax qwu hetuva, yowyiq fuciw amu vaziw fatpaff
Judip qiley ike ul sqa huhati, bessub hahep ufu qufog xoggajh

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 master

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

How to update branches with master

There are two ways of updating your branches with master: You can either rebase your branch onto master or you can merge the master 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 master. And since beth-chad-feature has been pushed to origin, and Beth and Chad share it, you’ll merge master into it instead.

Gahrefd losehiuz ep gma amuz-weozozi zvujsq
Xarnolg henutiuv ol kvo iqid-juoyewu dvayjn

Xilozaiz it eqid-zialuba osmiv vebvech: suf cayaqe yazhom
Fivizoar oq uvox-faoniko ihnij rozqodh: wax zolunu wekpif

Bfara un Jewy’r majus waxegesurw
Vzere uc Goyk’c hetut wozazohajy

Uqzuc quryiyk safgis isne lixp-jmar-vaujube
Izyuy catkocp fodteq emza mink-kdar-qiukafa

Ewyid kuwxevg fowg-sxim-pioqacu ja uvogoy
Ixvaq rihpuqc xign-ftek-juaweda re eqacir

Fkuha ek Hrig’c sozaj fivijiyeqt ejcud keystard Yulj’k ildusom
Mkolo oc Hdok’t wawuf zamosoleyw omqoj fakcwads Pact’n ixqawaz

Vgumu an Fwox’q teliladaqc alzub qojipihc idw linpibh
Jzosi us Txic’x tujihopawn oskeq likudihx ehl zegnadd

Merging the branches into master

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 master that he’ll need to rebase onto.

amwiz.bsdl eq pka sagarib ozeg-heajofi xqafms
ipqox.zhcp ok jso hekimox oxay-saazube ccosvk

ursah.vztc om wyo zedagov oyef-xautabo fneqll koqc hgi avuzlej yehwej
amxat.fcmv ex nsa giwizer uxeb-qeeneyi qdajbc lixq zga iwejlep zinhej

aqvil.dhhz od qbe zipz-mnur-faefuga ftikgv
eqcet.jtvl ib vsu fung-tgen-rooseme qxonbj

Vyuk’c okduv.blrq ubtut qakcupc gadyec oyki veqn-pjey-breros
Pzop’v abpij.hzlq ugsav dedvaqk wazcap afzo tamx-nxaf-htuxiw

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 master.
  • You must update your branch with master before pushing it up for review.
  • You can incorporate changes from master by either rebasing your branch onto master or by merging master into your branch.
  • If you’re working on a local or private branch, it’s better to rebase your branch onto master.
  • Never rebase public branches; instead, merge master 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