5

As in the title: "How to go back to last commit + delete all newly created file?" Thanks.

DevWL
  • 17,345
  • 6
  • 90
  • 86
  • possible duplicate of [How to undo the last Git commit?](http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit) – Shimon Rachlenko Sep 29 '13 at 11:01

4 Answers4

7

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.

Mike Monkiewicz
  • 4,481
  • 1
  • 22
  • 19
1

git reset --hard HEAD^1

This will wipe off your working directory files.

Shunya
  • 2,785
  • 2
  • 18
  • 17
1
git reset --hard <commidId>

then

git clean -f
Zakaria
  • 983
  • 15
  • 24
0

Use git reset as in this answer

you can see the full documentation here

Community
  • 1
  • 1
dax
  • 10,779
  • 8
  • 51
  • 86