Rebase configuration presets¶
Rebase configuration presets refer to the set of Git configuration options that automate the inclusion of rebase operations during standard synchronization commands like git pull.^[600-developer-tools-git-git-rebase.md] These settings allow developers to modify the default behavior of Git to prioritize linear history and avoid unnecessary merge commits.^[600-developer-tools-git-git-rebase.md]
Configuration Options¶
Users can apply these settings globally to affect all repositories or locally for specific projects.
Branch-Specific Behavior¶
To configure a specific branch (e.g., master) to always rebase when pulling, the following command is used^[600-developer-tools-git-git-rebase.md]:
git config branch.master.rebase true
This modifies the .git/config file to set rebase = true for that branch, ensuring that git pull effectively performs a git fetch followed by a git rebase rather than a git merge.^[600-developer-tools-git-git-rebase.md]
Automatic Setup for New Branches¶
To avoid manually configuring every new branch, Git provides an option to automatically set the rebase property for newly created branches^[600-developer-tools-git-git-rebase.md]:
git config branch.autosetuprebase always
When set to always, any new branch tracked from a remote repository will automatically be configured to use rebase by default.^[600-developer-tools-git-git-rebase.md]
Global Default Configuration¶
For a workflow that consistently prefers rebasing over merging, these options can be applied globally using the --global flag^[600-developer-tools-git-git-rebase.md]:
git config --global pull.rebase true
git config --global branch.autoSetupRebase always
This ensures that git pull defaults to git pull --rebase across the user's entire development environment.^[600-developer-tools-git-git-rebase.md] To revert these global changes, the --unset flag can be used^[600-developer-tools-git-git-rebase.md]:
git config --global --unset pull.rebase
git config --global --unset branch.autoSetupRebase
Related Concepts¶
- Git Rebase
- [[Git Workflow]]
Sources¶
600-developer-tools-git-git-rebase.md