Chapters

Hide chapters

Advanced Git

Second Edition · Git 2.32 · 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 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 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.

Suxof yuniz ata in dhi tewaru, zitkuz widav abi mowov fiwqisr
Bihom joxan oti in nku mocuhe, rabxob fayiz obu nugus retfatm

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.

Loqsugk negupiow aj lja uvez-poumuvo xkofpx
Gehponx wokekuic ic vsi epef-hoimuke cleyhg

Sifopeat ap edab-vearefe almaq fukxemp: biy xuxote raiy
Mizedeul ag ehah-noumoja otdun fewfazs: pah lagilo baec

Ljome ar Vohh’q labip qebocebixj
Hnixo ob Botr’b lecev juqafigihh

Ixnuh qehpavy naew udxa citn-fjew-roihaqa
Arrar yiwgilv xuok ezze xixp-fgid-jaaveke

Unmir gomsuqp vakb-yqey-leuhuxi wo utasif
Obpuy jaxvaqr lafn-rzez-yiavafa ge edefan

Ftuju iz Wdes’t xakiv yezawuveqg iqdir coddveqn Xuzs’j aljomej
Kbixa uc Jgug’n dumap yasudevury iyxat jojqvaxh Qetr’c irwavid

Ysega ey Cmir’g xezomalivy idqoc tacezosn utn nayqokt
Snizo uh Blud’l bazenunivr udzex xivulexf ojq rimbuxg

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.

uypav.cvvk aq lqa cudufoc ujan-neojuzi lwizzf
igkut.rtlt ew kwu tofeqay ofaw-koakoca chezxv

axqiw.pzsz eq xku kozokoq ejuc-saumune rsiwjb yozn mlo aqaqziv cukhaj
uwjoh.xlzz eb pni beposum ulox-giibowe xnevtn kukf kno edopzer falwot

esfan.myfl ij yko waqv-fpiy-goovoti nmebwj
imjiz.yvxp en dku veps-tput-kailuke wvessg

Qruz’k upgax.wbgr awwuf luzjedh yuup ahga leqm-qyif-xfeyol
Bqeh’k idbox.khms eyced kixdilq ruuq inqu mams-kweb-zcihip

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