Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.73 KB

File metadata and controls

42 lines (29 loc) · 1.73 KB

Tutorial - Part 7: Updating a branch with a rebase

When git machete status shows a branch with a red edge, it means the branch is out of sync with its parent.

The update command

To sync the current branch with its parent, run:

git machete update

This command performs a rebase of the current branch onto its parent branch (as defined in .git/machete).

Fork point mechanism

A key feature of git-machete is its ability to find the correct fork point. It's the commit after which the unique history of your branch actually started, even if the parent branch has been switched since the commits were created, or the parent has been rebased itself.

If you've ever manually rebased a branch that was already rebased before, you might have ended up "reapplying commits" that were already there. git-machete avoids this by tracking the fork point of each branch. Fork point for the given branch (or the current branch, if none is specified) can be checked with:

git machete fork-point [<branch>]

If the automatic discovery ever fails, you can override it with the --fork-point flag in update and a few other commands:

git machete update --fork-point <commit-hash>

Benefits of update

As compared to a vanilla git rebase:

  • No need to remember parents — git-machete knows exactly what to rebase onto.
  • No need to specify commit range in most corner cases — it uses the fork point to ensure only the commits unique to your branch are rebased.
  • Simple — one command to keep your feature branch up to date with develop or its parent branch.

< Previous: Navigating between branches | Next: Squashing and reapplying >