brite, a MVC Framework for jQuery

Git: Merging patches git am -3 vs git apply

January 8th, 2010 by jeremychone

Merging patches

When git-am fails to cleanly apply It will ask you to apply it yourself, to  git add the file and to run git-am --resolved.
In fact, git-am can help you a lot. When the call to git-am for a patch fails, simply run :

git-am --3way

Il will merge the file that can be automatically merge. Some files may be marked with CONFLICT and in this case, edit them to do a manual merge, and once they are fixed and run

git add $FILES_IN_CONFLICT
git-am --resolved

Merging workflow

  • I’d recommend using File -> Save As, selecting “Raw Message Source”
    as the format, then apply using:

    % git am < /path/to/saved/message
  • Consider creating a topic branch for applying the patch and then
    merging that to master. e.g.

    % git checkout -b bugfix_from_john master
    % git am < /path/to/saved/message
  • Check things out. Make minor edits if needed. You can then use “git
    add” to add in your edits and “git commit –amend” to make those
    changes part of the patch the author sent.
  • Once you’re happy:
    % git checkout master
    % git merge bugfix_from_john
    % git branch -d bugfix_from_john

Comments are closed.