Read Anthropic’s case study about Graphite Reviewer

Configuring git config pull.rebase false

Greg Foster
Greg Foster
Graphite software engineer


Note

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


In Git, the configuration settings can drastically alter how commands behave, which in turn affects your development workflow. One such configuration is git config pull.rebase false, which defines how changes from a remote branch should be integrated into your current branch when executing git pull. This guide will explain the implications of this setting and how it affects your Git operations.

Rebasing in Git is a process of integrating changes from one branch onto another by reapplying each commit from the source branch onto the target branch. This differs from merging, where Git creates a merge commit to combine the changes. When you rebase, Git moves the entire branch to begin from the tip of the target branch, then sequentially reapplies each commit from the source branch one by one. This results in a linear history, making it easier to follow the evolution of the codebase and resolve any conflicts that may arise during the rebase process. Rebasing is commonly used to maintain a clean and linear history, especially in collaborative workflows where feature branches are frequently created and merged.

By default, when you run git pull, Git will perform a fetch followed by a merge. This means it fetches changes from the remote repository and merges them into your current branch. The merge operation creates a new "merge commit" if there are any divergent changes, preserving the history of both branches.

Join 20,000+ developers at top companies
Stop wrestling with Git commands
The Graphite CLI takes all the pain out of Git, allowing you to ship faster and stop googling Git commands.
main
diff1
diff2

While Git is an incredibly useful tool, it has many shortcomings, particularly with rebasing, and managing stacked pull requests.

The Graphite CLI simplifies git, handles rebasing automatically, and allows you to create, submit, and stack pull requests right from the command line.

Under the hood, the CLI runs Git to create branches, commits, and metadata, which means you can still use Git in your scripts, tooling, or whenever you feel like it. Read more about installing the Graphite CLI in our docs.

screenshot of the Graphite CLI

When you set git config pull.rebase false, you explicitly tell Git to avoid using the rebase strategy when pulling changes. Instead, it ensures that Git will always merge the changes. This configuration is particularly useful if you want to maintain the exact history of changes, including merge commits.

You can configure this setting at different levels (local, global, or system), but typically it's set at the local repository level for specific project preferences.

To locally configure the default behavior of the Git pull command run:

Terminal
git config --local pull.rebase false

This command sets the configuration only for the current repository. If you want to set it globally (i.e., for all your Git projects), you can replace --local with --global.

Imagine you're working on a feature in a branch called feature-x and you have set git config pull.rebase false. Your colleague has made updates to the same branch and pushed them to the remote repository. Here’s how you would pull those changes:

Terminal
git checkout feature-x
git pull origin feature-x

Since pull.rebase is set to false, this operation will fetch the changes from origin/feature-x and merge them into your local feature-x branch, creating a merge commit if necessary. This merge commit is a record of the integration, showing a convergent point of the diverged branch histories.

  • Preservation of history: Every merge is documented, including the context of changes. This can be crucial for understanding the history of a project.
  • Avoidance of potential confusion: Rebasing can rewrite commit history, which might confuse or disrupt others who are basing their work on the branch.
  • Simplification for beginners: Newcomers to Git might find merging more straightforward to understand than rebasing, making it a less error-prone choice.
Join 20,000+ developers at top companies
The best engineers use Graphite to simplify Git
Engineers at Vercel, Snowflake & The Browser Company are shipping faster and staying unblocked with Graphite.
main
diff1
diff2

While disabling rebase can be beneficial for preserving history, there are situations where rebasing might be preferable:

  • Maintaining a linear project history: If a clean, linear history is crucial for your project’s workflow, rebasing might be more appropriate.
  • Large projects with frequent merges: Continuous merging in large projects can create a complex commit graph that's hard to navigate.

For further reading see the official Git documentation.

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