Skip to content

Pull with rebase

Pull with rebase is a Git workflow variant used to synchronize local changes with a remote repository. Instead of creating a merge commit, this method rewrites local history to place commits on top of the incoming remote changes.^[600-developer-tools-git-git-rebase.md]

Usage

The core command combines fetching and rebasing into a single step:^[600-developer-tools-git-git-rebase.md]

git pull --rebase

This workflow is typically used when multiple developers are working on the same branch. It modifies the local history to ensure a linear project history.^[600-developer-tools-git-git-rebase.md]

Configuration

To avoid typing the --rebase flag manually every time, Git can be configured to use rebase by default for git pull.^[600-developer-tools-git-git-rebase.md]

  • Specific Branch: Configure a specific branch (e.g., master) to always rebase when pulling^[600-developer-tools-git-git-rebase.md]:
    git config branch.master.rebase true
    
  • Global Behavior: Configure all branches (or new branches) to prefer rebasing during a pull^[600-developer-tools-git-git-rebase.md]:
    git config --global pull.rebase true
    git config --global branch.autoSetupRebase always
    

To unset these configurations, use the --unset flag^[600-developer-tools-git-git-rebase.md].

  • [[Rebase]]
  • [[Git merge]]

Sources

  • 600-developer-tools-git-git-rebase.md