Branches and Code Reviews

Sports Store uses Git, a decentralized version control system. Git encourages small, short-term branches that are often merged back to a parent branch.


This screenshot depicts the branches used by Sports Store. The master branch contains the production codebase. The sprint branch is comprised of the codebase for the current sprint. Each user story has a short-lived branch known as a feature branch.

When a set of code is ready for review or testing, a pull request is made into a parent branch. This invokes a process whereby all changes must be reviewed and approved or rejected. The pull request facilities peer code reviews.

Fix A Bug – Example

In this example, we will fix a bug in the system using Visual Studio and Visual Studio Team Services. We will create the feature branch, make the code change, and perform a pull request as well as a code review.


The bug we will fix is the number in the header that incorrectly displays the item count in the cart. It displays 2, but there is only one item in the cart.


The above screenshot depicts the user story for the bug. We can create a new branch for the story by clicking the Create a New Branch link. We will name the branch 579_Incorrect_Quantity  and base it on the current sprint branch.


We have created a local branch on our development machine for the 579_Incorrect_Total branch. We change @Model.Lines.Sum(x => x.Quantity + 1) item(s) to @Model.Lines.Sum(x => x.Quantity) item(s). Then we commit the code  and sync the changes.

Pull Request.png

We created a pull request, and we can see the changes that were made. We performed a code review and posted a comment on the change.

Build In Progress.png

When the pull request is accepted, the build for the sprint branch is processed .
We will discuss builds next.

Learn More

For details on the topics covered in this article, please visit the links below. You may also download the source code for the DevOps Roadmap Lab on Git Hub. Contact me to set up a free meeting where we can dive deeply into the lab material  and discuss your individual needs.

  • Git functionality was added to Team Services and Visual Studio in 2013. This article on Git functionality is good  because you can tailor it to the version of Visual Studio you are using.
  • This article discusses some of the branching strategies available to Git. It talks about features branches like the ones we use in the DevOps Roadmap Lab.
  • You can see the details of creating a branch from a user story here