LinuxCommandLibrary

git-imerge

Incrementally merge changes from one branch to another

TLDR

Start imerge-based rebase (checkout the branch to be rebased, first)

$ git imerge rebase [branch_to_rebase_onto]
copy

Start imerge-based merge (checkout the branch to merge into, first)
$ git imerge merge [branch_to_be_merged]
copy

Show ASCII diagram of in-progress merge or rebase
$ git imerge diagram
copy

Continue imerge operation after resolving conflicts (git add the conflicted files, first)
$ git imerge continue --no-edit
copy

Wrap up imerge operation, after all conflicts are resolved
$ git imerge finish
copy

Abort imerge operation, and return to the previous branch
$ git imerge remove && git checkout [previous_branch]
copy

SYNOPSIS

git-imerge subcommand [options] [arguments]

PARAMETERS

start tip
    Initialize incremental merge or rebase from tip commit/branch. Use --name=<name> to label the merge.

diagram [--graphviz]
    Display ASCII or Graphviz diagram of merge progress and pending steps.

continue [--skip]
    Advance to next merge step after resolving conflicts. --skip ignores current step.

merge [--no-ff] commit
    Merge a specific commit into current state, optionally without fast-forward.

rebase [-i] commit
    Rebase onto commit, with -i for interactive mode.

finish [--rename]
    Complete the incremental merge and integrate into target branch.

simplify
    Collapse linear merge steps into a single commit.

drop step
    Remove a specific merge step from the plan.

--first-parent
    Treat merges as first-parent only, simplifying octopus merges.

--no-commit
    Perform merges without auto-committing.

DESCRIPTION

git-imerge is a third-party command-line tool that enables incremental merging and rebasing in Git repositories. Unlike standard git merge or git rebase, which can fail catastrophically on large or complex changesets due to massive conflicts, git-imerge breaks the process into smaller, manageable steps.

It creates a temporary branch where merges are performed incrementally, commit by commit or range by range. Users can visualize progress with ASCII diagrams, resolve conflicts step-by-step, and advance or rewind as needed. This is particularly useful for integrating long-lived feature branches, rewriting history without losing work, or handling merges across divergent histories.

Key benefits include reduced conflict resolution time, better visibility into merge progress, and the ability to simplify or drop problematic merges. Once complete, it can finalize the merge into the target branch. It's especially valuable in large projects like the Linux kernel where standard merges often require manual intervention.

Implemented in Python, it integrates seamlessly with Git but requires separate installation.

CAVEATS

Third-party tool, not part of core Git; alters reflog and may require manual cleanup on errors. Not suitable for shared repositories during active use. Python dependency required.

INSTALLATION

Install via pip install git-imerge or clone from GitHub and run make install. Requires Git 1.8+ and Python 3.

TYPICAL WORKFLOW

git-imerge start feature-branch
git-imerge diagram # view plan
git-imerge continue # resolve & advance
git-imerge finish

HISTORY

Developed by Michael Haggerty starting in 2014 to address limitations in Git's merge/rebase for large histories. First released on GitHub; actively maintained with contributions from Linux kernel developers. Gained popularity for kernel topic branch integration.

SEE ALSO

Copied to clipboard