[Sugar-devel] Adjusting/reworking patches with git (was: Re: Patch:

Michael Stone michael at laptop.org
Mon May 31 12:07:50 EDT 2010


Excerpts from James Cameron's message of Mon May 31 10:59:18 +0000 2010:

>> 1.  "git checkout HASH" where hash is the patch to be fixed,
>> 
>> 2.  "git reset HEAD^" to undo this last commit without changing the
>> working copy, then
>> 
>> 3.  "git add" and "git commit" again.
> 
> Even easier to use is "git rebase -i origin/master" (where origin/master
> is the upstream branch). 

Tagging with a throwaway tag (e.g. "good") before interactive-rebasing has
saved me a lot of time because it's much easier to remember "git reset --hard
good" than to read the output of "git reflog" to get back to the working but
ugly patch that you haven't yet pushed.

Also, another trick that has been quite handy for splitting up big patches is:

   git add -p

(which is an abbreviation for "git add -i; p; *;")

Michael


More information about the Sugar-devel mailing list