The git provides a lot of features where resetting file is one of them. We can use different commands to reset files in git. In this tutorial we examine the git reset commands to reset staging, specific commits, or local changes.
Reset Staging File
We can reset the staging file by using the
git reset command with the
$ git reset HEAD -- conf/main.c
Reset File To Specific Commit
git checkout command is used to check different branches’ commits etc. We can reset a file into a specific commit by providing the commit ID and file name.
$ git checkout 2ad245ffeb -- conf/main.c
Reset Local Changes
We can also reset local changes before staging. We just use the “git checkout” with the file name like below.
$ git checkout -- conf/main.c