git

Git - Soft Reset

Every so often, I foobar something in git and accidentally add a bunch of crap to the repo. Traditionally and ignorantly, I've just done a git reset --hard and lose my work, which was OK. However, I came to a point where I could NOT lose my work. Solution:

git reset --soft HEAD^

The above command basically undoes your previous commit and puts everything back onto staging. Particularly, HEAD^ is the identifier of that state prior to the commit.

Ref: http://stackoverflow.com/questions/5473/undoing-a-git-reset-hard-head1

Syndicate content