El 16/4/2008, a las 16:21, Garry Hill escribió: > > incidentally, since git claims to track content rather than files, is > there a clever, gittish, way to revert single line changes within a > single commit? i just had to make prolific use of the undo key and > there's gotta be a better way...
You can _stage_ individual hunks using: git add --interactive (See also "git add -i", "git add --patch" and "git commit -- interactive") But if you already committed, there's no built-in way to select individual hunks for reversion. Note that "revert" has special meaning in Git; it means to revert the effect of a particular commit without going back and altering the history of the repo. It's also known (and internally implemented) as a "reverse cherry-pick". A different notion is that of "resetting", which involves going back to an earlier point in the history so that you can change the commit(s). See the "git-reset" man page for details on the different types of reset that you can do. For more complicated history manipulation their's "rebasing" (see the man page for "git-rebase", especially "git rebase --interactive"). Obviously, because resetting and rebasing changes the history you should only do it on non-public repos, otherwise you may be making life harder for people who have cloned your repo and are trying to track what you do. So, in a non-public repo, which I assume yours is, you can just redo the commit: git reset HEAD^ git add --interactive # or whatever In a _public_ repo you'd have to do a real revert, and the easiest way to do that it probably produce a reverse patch corresponding to the commit that you want to partially counteract, edit the patch to remove the hunks which shouldn't be reverted, and then apply it. Something like this would work; here I'm making a reverse patch for the changes introduced from "three versions ago" to "two versions ago", editing it, and reapplying: git diff HEAD~2 HEAD~3 > the_patch $EDITOR the_patch git apply the_patch git commit # ... Cheers, Wincent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
