Skip to content

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>
Code language: Bash (bash)

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

git reset ./the/actual/relatvive/path/with/filename.ext
Code language: Bash (bash)

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>
Code language: Bash (bash)

Reset an entire branch

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

git reset --hard HEAD
Code language: Bash (bash)

See also  Convert Array to Tree in Java
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x