On Sat, May 26, 2012 at 4:40 PM, Tormod Volden <lists.tor...@gmail.com> wrote:
> To remove the latest commit in your own git tree, run
>  git reset --hard HEAD^
> This resets the tree to the current 2nd commit (HEAD is a short for
> the top commit, HEAD^ is second, HEAD^^ us third, etc.).

Great, this works perfectly.

I accomplished what I wanted to do with the following commands.
The 3 nano command is just to remove the leading ">" from
the patches which is a problem of the mailing list software.

  516  git reset --hard HEAD^
  517  git log
  520  nano Darwin-Align-severity-of-OS-X-logging-messages-v2.patch
  521  nano 0001-Core-Define-log-levels-in-libusb.h.patch
  522  nano 0002-Core-Only-display-timestamps-in-debug-mode-and-use-i.patch
  523  git am Darwin-Align-severity-of-OS-X-logging-messages-v2.patch
  524  git am 0001-Core-Define-log-levels-in-libusb.h.patch
  525  git am 0002-Core-Only-display-timestamps-in-debug-mode-and-use-i.patch
  527  git log

> (On the other hand if the commit has already been pushed to a public
> repo, you should not change it. Then you have to *add* a reverting
> commit with "git revert".)
>
> BTW, if you for example want to remove the second last commit and keep
> the last one, you have several options:
> 1. Remove the two commits, then cherry-pick the last one (refer to it
> by commit id, it is still in the git repo but not attached to any
> head).
> 2. Use git rebase -i HEAD^^ and change the order of the two commits,
> then git reset --hard HEAD^ to drop the last one.

This is good to know. I should have asked the question earlier
(I was googling around but did not find a good simple reference)
and the above is indeed what I wanted to do the other day.

> FYI, git reset without --hard does not reset the files, only removes
> the commit action. So it can for instance be used to split the last
> commit into several commits, by selectively adding changes to each new
> commit with "git add" (per file) or "git add -p" (per hunk).


-- 
Xiaofan

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to