Git discard all changes - How to undo all working dir changes including new files?

596    Asked by HarryADAMS in Devops , Asked on Apr 21, 2021

How to delete all changes from the working directory including new untracked files. I know that git checkout -f does that, but it doesn't delete new untracked files created since the last commit.

Does anybody have an idea how to do that?

Answered by Harry ADAMS

Simple way to solve git discard all changes is:



Step 1: Revert modified files using the following command:

  $ git checkout -f

Step 2: Remove untracked files:

  $ git clean -fd


Your Answer

Interviews

Parent Categories