Reset changes

git reset

This command resets the changes in the working directory to the last commit. The changes in the staging area are preserved. The changes in the working directory are not preserved. The changes are not committed to the repository. The changes are not pushed to the remote repository.

for a specific file

example:file.txt

git reset file.txt

This command resets the changes in the working directory for the specified file to the last commit. The changes in the staging area are preserved. The changes in the working directory are not preserved. The changes are not committed to the repository. The changes are not pushed to the remote repository.

for a specific commit

example:HEAD~1

git reset HEAD~1

This command resets the changes in the working directory to the specified commit. The changes in the staging area are preserved. The changes in the working directory are not preserved. The changes are not committed to the repository. The changes are not pushed to the remote repository.

for a specific commit and preserve changes

example:HEAD~1

git reset --soft HEAD~1

This command resets the changes in the working directory to the specified commit. The changes in the staging area are preserved. The changes in the working directory are preserved. The changes are not committed to the repository. The changes are not pushed to the remote repository.

for a specific commit and discard changes

example:HEAD~1

git reset --hard HEAD~1

This command resets the changes in the working directory to the specified commit. The changes in the staging area are discarded. The changes in the working directory are discarded. The changes are not committed to the repository. The changes are not pushed to the remote repository.