Read Anthropic’s case study about Graphite Reviewer

Understanding the Git workflow

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Understanding the Git workflow for version control is important for efficient team collaboration and effective project management. This guide delves into the standard Git workflows, focusing particularly on the Git feature branch workflow.

There are several types of Git workflows that teams can adopt depending on their size, project requirements, and management style. Here are a few of the most popular ones:

  1. Centralized workflow

    • Similar to SVN, this workflow uses a central repository as the single point-of-entry for all changes to the project.
    • Developers clone the repository, make changes locally, and push updates back to the central repo.
  2. Feature branches

    • This workflow encourages developers to create new branches for each new feature, keeping them separate from the main codebase.
    • Features are merged into the main branch only after completion and testing, which enhances the stability of the project.
  3. Gitflow

    • An extension of the feature branch workflow, Gitflow is optimized for projects that have a scheduled release cycle.
    • It involves multiple branches for managing different levels of stability and multiple simultaneous development streams.
  4. Forking

    • This workflow is often used in open-source projects where contributors do not have direct access to the main repository.
    • Contributors fork the repo, make changes in their fork, and then submit a pull request to have their changes integrated into the main repo.

The feature branch workflow is a classic Git workflow that supports team collaboration while isolating new features from the main codebase. Here’s a detailed look at how it works:

Whenever you start work on a new feature, you create a new branch off the main branch:

Terminal
git checkout -b new-feature

This ensures that your main branch (usually called main) always contains production-quality code.

You make all changes for the new feature within this branch. This isolation allows you to commit all changes related to the feature:

Terminal
git add .
git commit -m "Add initial new feature"

To ensure that the feature branch stays up-to-date with the main branch, regularly pull changes from the main branch into your feature branch:

Terminal
git checkout new-feature
git pull origin main

Once the feature is complete and tested, it’s merged back into the main branch:

Terminal
git checkout main
git merge new-feature

After the feature has been merged, the feature branch can be deleted to keep the repository clean:

Terminal
git branch -d new-feature

Choosing the right Git workflow is a strategic decision that can enhance your team's productivity and project quality.

To supplement your Git workflow it's also important to choose the right tooling on top of Git. Use a tool like Graphite to accelerate your engineering productivity, and take the complexity out of Git workflow management.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2