37 | Resetting Staged Changes and Commits |
The git reset
command lets you change
the HEAD
âthe latest commit your working
tree points toâof your repository. It modifies either the
staging area or the staging area and working tree.
Gitâs ability to craft commits exactly like you want means that you
sometimes need to undo changes to the changes you staged with
git add
. You can do that by calling
git reset HEAD <file to change>
.
This is the most common use of the
reset
and is like Subversionâs
svn revert
command. Remember not to get
the two confused. (For more on git
revert
, see Task 36, âReverting Commitsâ.)
You have two options to get rid of changes completely.
git checkout HEAD <file(s) or
path(s)>
is a quick way to undo changes ...
Get Pragmatic Guide to Git now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.