Rebase a branch
Rebasing is a powerful operation that updates a branch with the latest changes from its parent branch. This is essential for maintaining branch health and ensuring smooth integration of changes.
note
Rebasing acts on the Infrahub branch in Infrahub's versioned graph database. It is distinct from git rebase: it does not rebase a connected Git repository, rewrite Git history, or push to a Git remote. For how Infrahub synchronizes with connected Git repositories, see Git integration.
Why rebase​
Rebasing serves several important purposes:
- Resolving conflicts before merge: Identify and address conflicts in the development branch before creating a Proposed Change, reducing complexity during the review process.
- Incorporating upstream changes: Ensure your branch includes the latest updates from the main branch, preventing drift and maintaining compatibility with recent changes.
- Maintaining a clean merge history: Produce a cleaner, more linear history that's easier to understand and navigate.
How rebase works​
During the rebase process, Infrahub performs the following steps:
- The branch's base point (
branched_from) updates to the current time, establishing a new foundation for the branch. - Changes in the branch are analyzed and replayed on top of the new base, incorporating the latest state from the parent branch.
- Conflicts that arise during this process require manual resolution, allowing developers to make informed decisions about how to integrate conflicting changes. See Resolve conflicts.
- The branch history resets, preserving only the final state. This simplification makes the branch easier to understand and work with.
How to rebase​
Rebasing can be initiated through the Infrahub user interface or API.
Related​
- Branches — branch lifecycle and concepts
- Resolve conflicts — when rebase surfaces conflicting changes
- Merge a branch — once rebase is complete and the branch is up-to-date