As in the title: "How to go back to last commit + delete all newly created file?" Thanks.
The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case.
Go back to the selected commit on your local environmentUse git checkout & the ID (in the same way you would checkout a branch) to go back: $ git checkout <commit-id> .
If I understand the question correctly, you've done a bunch of work, haven't committed it, and want to git rid of that work and go back to your last commit. Is that correct? If so, I think you need a combination of two commands:
git reset --hard # reverts tracked files to commit you were working from
git clean -f # removes untracked files that haven't been added to git yet
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With