If you just want to clean unstaged changes on Git in your current working directory execute the following ‘Git discard all changes’ command ’:
git checkout — .
How to Delete a Git Branch Locally and Remotely
If however you are referring to a specific existing file, simply add the file path as follows :
git checkout — thepathtothefile/to/discard
For newer Git releases however you would want to use the restore command :
git restore . [Git discard changes command]
And for a specific file :
git restore thepathtothefile/to/discard [Git revert changes for a file]
Answer due to Tobi.
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.