Coder Social home page Coder Social logo

git-imerge's Introduction

git-imerge -- incremental merge and rebase for git

Perform a merge between two branches incrementally. If conflicts are encountered, figure out exactly which pairs of commits conflict, and present the user with one pairwise conflict at a time for resolution.

git-imerge has two primary design goals:

  • Reduce the pain of resolving merge conflicts to its unavoidable minimum, by finding and presenting the smallest possible conflicts: those between the changes introduced by one commit from each branch.
  • Allow a merge to be saved, tested, interrupted, published, and collaborated on while it is in progress.

I think that it is easiest to understand the concept of incremental merging visually, and therefore I recommend the video of my git-imerge presentation from the GitMerge 2013 conference (20 min) as a good place to start. The full slides for that talk are available in this repository under doc/presentations/GitMerge-2013. At the same conference, I was interviewed about git-imerge by Thomas Ferris Nicolaisen for his GitMinutes Podcast #12.

To learn how to use the git-imerge tool itself, I suggest the blog article git-imerge: A Practical Introduction and also typing git-imerge --help and git-imerge SUBCOMMAND --help. If you want more information, the theory and benefits of incremental merging are described in minute detail in a series of blog articles [1], as are the benefits of retaining history when doing a rebase [2].

Multiple incremental merges can be in progress at the same time. Each incremental merge has a name, and its progress is recorded in the Git repository as references under refs/imerge/NAME. The current state of an incremental merge can be visualized using the diagram command.

An incremental merge can be interrupted and resumed arbitrarily, or even pushed to a server to allow somebody else to work on it.

git-imerge is experimental! If it breaks, you get to keep the pieces. Feedback and bug reports are welcome!

Requirements

git-imerge requires:

  • A Python interpreter; either

    • Python 2.x, version 2.6 or later. If you are using Python 2.6.x, then you have to install the argparse module yourself, as it was only added to the standard library in Python 2.7.
    • Python 3.x, version 3.3 or later.

    The script tries to use a Python interpreter called python in your PATH. If your Python interpreter has a different name or is not in your PATH, please adjust the first line of the script accordingly.

  • A recent version of Git.

Instructions

To start a merge or rebase operation using git-imerge, you use commands that are similar to the corresponding git commands:

Starting an incremental merge or rebase
git command git-imerge equivalent
git merge BRANCH git-imerge merge BRANCH
git rebase BRANCH git-imerge rebase BRANCH

For more flexibility, you can start an incremental merge using git imerge start:

git-imerge start --name=NAME --goal=GOAL --first-parent BRANCH

where

NAME
is the name for this merge (and also the default name of the branch to which the results will be saved).
GOAL describes how you want to simplify the results (see next
section).

After the incremental merge is started, you will be presented with any conflicts that have to be resolved. The basic procedure is similar to performing an incremental merge using git:

while not done:
    <fix the conflict that is presented to you>
    <"git add" the files that you changed>
    git-imerge continue

When you have resolved all of the conflicts, you finish the incremental merge by typing:

git-imerge finish

That should be enough to get you going. All of these subcommands have additional options; to learn about them type:

git-imerge --help
git-imerge SUBCMD --help

Simplifying results

When the incremental merge is finished, you can simplify its results in various ways before recording it in your project's permanent history by using either the finish or simplify command. The "goal" of the incremental merge can be one of the following:

merge

keep only a simple merge of the second branch into the first branch, discarding all intermediate merges. The end result is similar to what you would get from

git checkout BRANCH1
git merge BRANCH2
rebase

keep the versions of the commits from the second branch rebased onto the first branch. The end result is similar to what you would get from

git checkout BRANCH2
git rebase BRANCH1
rebase-with-history

like rebase, except that it retains the old versions of the rebased commits in the history. It is equivalent to merging the commits from BRANCH2 into BRANCH1, one commit at a time. In other words, it transforms this:

o---o---o---o          BRANCH1
     \
      A---B---C---D    BRANCH2

into this:

o---o---o---o---A'--B'--C'--D'   NEW_BRANCH
     \         /   /   /   /
      --------A---B---C---D

It is safe to rebase an already-published branch using this approach. See [2] for more information.

full
don't simplify the incremental merge at all: do all of the intermediate merges and retain them all in the permanent history.

License

git-imerge is released as open-source software under the GNU General Public License (GPL), version 2 or later.

References

[1]
[2](1, 2)

git-imerge's People

Contributors

mhagger avatar jherland avatar andersk avatar arodland avatar peff avatar blitz avatar mindjiver avatar knirch avatar

Watchers

Arkady Shapkin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.