How to Git Reset a Single File

It’s very easy to reset files that have not yet been committed to git.

Reset a single file

git reset <filename>

You can also specify the filename as the path to the file, like so:

git reset ./the/actual/relatvive/path/with/filename.ext

This will checkout the file from HEAD.

It is important to note that should you have a file that is the same name as a branch, you will need to rather run the following command:

 git reset -- <filename>

Reset an entire branch

To reset an entire branch, you can reset it directly against the HEAD.

git reset --hard HEAD