There's new GIT instructions on Github now

David Nadlinger see at klickverbot.at
Sat May 21 02:33:48 PDT 2011


On 5/21/11 12:05 AM, Andrej Mitrovic wrote:
> I would also like to know how to uncommit a change which hasn't been
> pushed yet. So if I locally do:
> git add someFile.d
> git commit -m "woops wrong comment"

If you just want to modify the commit, e.g. because you made a typo in 
the message, forgot some files, etc., use »git commit --amend«:

git add someFilePreviouslyLeftOut.d
git commit --amend …

(This will obviously change an existing commit, don't do it if you have 
already pushed your changes somewhere else.)


To, entirely remove the, say, two last commits from history, but not 
modify the contents of the files in your working tree, use »git reset«:

git reset HEAD~2 (or HEAD^ for just one commit)


> I'd like to just uncommit that message. I couldn't find an easy way to
> do this. Isn't this just hg revert on mercurial?

Nope, hg revert checks out individual files from a recorded changeset 
(usually the last), much like »git checkout some/file«. If you want to 
remove the last two commits like above, say r1001 and 1002, you have to 
do something like this:

hg update -r1000
hg revert -all -r1002
hg strip --force 1001


David


More information about the Digitalmars-d mailing list