Skip to content

Git rebase configuration

Git rebase configuration allows developers to modify how Git integrates changes from a remote repository, specifically by setting git pull to use rebase instead of merge by default^[600-developer__tools__git__git-rebase.md].

Purpose

The primary goal of this configuration is to maintain a cleaner project history. When pulling updates from a remote server, standard Git behavior creates an unnecessary merge commit if the local history has diverged. Configuring Git to rebase on pull avoids these merge bubbles, resulting in a linear, easier-to-read history^[600-developer__tools__git__git-rebase.md].

Configuration Options

There are several ways to configure this behavior, ranging from global settings that affect all repositories to local settings for specific branches[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:67-68].

Global Configuration

To enable rebase by default for all branches (globally), use the following command[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:67-68]:

git config --global pull.rebase true

To automatically configure new branches to use rebase, you can set the autoSetupRebase variable[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:67-68]:

git config --global branch.autoSetupRebase always

To remove these global settings later, use the --unset flag[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:70-71]:

git config --global --unset pull.rebase
git config --global --unset branch.autoSetupRebase

Branch-Specific Configuration

To configure rebase for a specific branch (e.g., master), you can set the property directly within the .git/config file or via the command line[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:48-49]:

git config branch.master.rebase true

File Representation

When configured, the .git/config file includes the rebase = true property under the specific branch section[600-developer__tools__git__git-rebase.md][600-developer__tools__git__git-rebase.md:56-59]:

[branch "master"]
    remote = origin
    merge = refs/heads/master
    rebase = true

Sources

  • 600-developer__tools__git__git-rebase.md