git reset <pathspec>
is the opposite of git add <pathspec>
.
git reset [<commit>]
resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated.
The command git reset <pathspec>
will change the index information but not make effect on working directory. It makes the index look like HEAD.
git reset -p
is the opposite of git add -p
. The reset command will accept a --patch
option to unstage content on a hunk-by-hunk basis.
Use Reset To Squash Commits
The original commits:
Move the HEAD back to an older commit and keep the staged files.
Squash commits: git commit -m "add cultrue.txt and shun.txt"
.
The practice court: Learn Git