Changes between Version 24 and Version 25 of GitForDarcsUsers


Ignore:
Timestamp:
Aug 15, 2008 2:53:08 PM (7 years ago)
Author:
nominolo
Comment:

how to amend non-HEAD commits

Legend:

Unmodified
Added
Removed
Modified
  • GitForDarcsUsers

    v24 v25  
    369369== darcs unpull ==
    370370
    371 unknown
     371This can be done with {{{git rebase}}}, but consider the consequences of what you are about to do (see "Git Concepts" above).
     372
     373Given a (partial) history like this
     374{{{
     375A---B---C---D---E <-- mybranch
     376}}}
     377you want to remove patch {{{C}}}.  Using interactive rebase, it can be done like this:
     378{{{
     379git rebase -i C^ mybranch
     380}}}
     381This opens your editor with a list of the commits {{{C}}}, {{{D}}}, and {{{E}}}.  By default they are labelled with {{{pick}}}.  Now remove the line for patch {{{C}}} and save your changes.  Git rebase will now check out version {{{B}}} and apply the remaining patches {{{D}}} and {{{E}}} in order, resulting in the desired outcome:
     382{{{
     383A---B---D'---E' <-- mybranch
     384}}}
    372385
    373386== darcs amend-record ==
    374387
    375 It is not easy to amend any patch except the last one committed.
    376 
    377388If the change to be amended is the latest commit
    378389{{{
     
    380391}}}
    381392
    382 TODO: describe workflow if amended patch is not the current HEAD.
     393If the patch is not the last commit you can also use {{{git rebase -i}}} as above, but instead of deleting the line, change {{{pick}}} to {{{edit}}}.  Rebase will then stop and let you edit the files.  Then do your edits, {{{git commit --amend}}}, then continue the rebase with {{{git rebase --continue}}}.
     394
     395You can do a lot more things with {{{git rebase -i}}}, like reordering changes or joining or splitting patches.  See the "Interactive Mode" section of {{{git rebase --help}}} for more information.
    383396
    384397TODO: add note for merge commits