How we use git at Shopify

Shopify Engineering
7 min readintermediate
--
View Original

Overview

The article discusses the Git workflow used at Shopify, emphasizing the importance of forking repositories, utilizing feature branches, and maintaining a clean commit history through rebasing. It provides practical commands and insights into daily usage, along with tips for effective Git management.

What You'll Learn

1

How to set up a Git workflow using forks and feature branches

2

Why rebasing is important for maintaining a clean commit history

3

When to use interactive rebase to squash commits

Prerequisites & Requirements

  • Basic understanding of Git and version control concepts

Key Questions Answered

How does Shopify manage Git workflows among developers?
Shopify manages Git workflows by having developers fork repositories, create feature branches for tasks, and use remotes to keep their forks updated. They emphasize rebasing to maintain a tidy commit history and ensure that the main repository remains clear of unnecessary merge commits.
What are the key branches used in Shopify's Git workflow?
The key branches in Shopify's Git workflow include 'production' for deployed code, 'staging' for testing features before deployment, and 'master' for completed features ready for deployment. Each branch serves a specific purpose in the development and release process.
What Git commands are essential for keeping a project up to date?
Essential Git commands for keeping a project up to date include 'git pull --rebase mainline master' to update the local master branch and 'git rebase master' to update feature branches. These commands help avoid merge conflicts and maintain a clean commit history.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Version Control
Git
Used for managing code changes and collaboration among developers.
Hosting Service
Github
Used for hosting repositories and managing forks.

Key Actionable Insights

1
Utilize feature branches to isolate work on specific tasks, which allows for easier collaboration and testing.
Feature branches enable developers to work independently without affecting the main codebase, making it easier to manage multiple features simultaneously.
2
Regularly rebase your feature branches to keep them updated with the latest changes from the main repository.
Rebasing helps to minimize merge conflicts and keeps the commit history clean, making it easier to understand the project's evolution.
3
Squash commits before merging feature branches into master to maintain a concise commit history.
Squashing commits reduces clutter in the commit log, making it easier for team members to review changes and understand the history of the project.

Common Pitfalls

1
Failing to keep feature branches updated with the main repository can lead to complex merge conflicts.
This happens when developers do not regularly pull changes from the mainline, resulting in a divergence that complicates integration later.
2
Not squashing commits before merging can clutter the commit history with unnecessary details.
This can make it difficult for team members to follow the project's evolution and understand the rationale behind changes.

Related Concepts

Version Control Best Practices
Git Branching Strategies
Continuous Integration Workflows