Section C.2 Uh Oh, I Committed Too Early!
We’ve all been there. You
add
all the files you need, double check to make sure you aren’t missing anything, commit
with a message and suddenly remember a file you should have added. Never fear, git reset
is here!Git Procedure C.2. Reversing
(a)
You will only need this command:
git reset --soft HEAD^1
. It should be safe to copy/paste this command directly into your command line and run it.(b)
git reset
gives no output so it is super important to check that the command worked with git status
(Git Procedure 4.4). If everything worked, you should see output as if you had used git status
after a git add
step.Depending on how many commits you made, you may need to run this above command more than once. If so, make sure to use
git status
after each try!(c)
Your previously staged files should still exist. From this point, use
git add
to add your missing file(s) and proceed with git commit
.