Configuring git config pull.rebase false

Greg Foster
Greg Foster
Graphite software engineer

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.

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:

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:

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.

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.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2