I accidentally committed all files with the command
git commit -m "Message" .
Where I wanted to actually run
git commit -m "Message" ./file
I haven't yet done a git push. How can I undo the last commit so all of these files don't get pushed?
I accidentally committed all files with the command
git commit -m "Message" .
Where I wanted to actually run
git commit -m "Message" ./file
I haven't yet done a git push. How can I undo the last commit so all of these files don't get pushed?
Use
git reset --soft HEAD^
For information, the git-reset
command resets the current branch to the specified commit (HEAD^
, here).
As for the --soft
option, it does not touch the index file nor the working tree at all, but requires them to be in a good order. This leaves all your changed files "Changes to be committed".
For more information, see the git-reset
man page.