git revert one file code example

Example 1: git revert one file

git checkout HEAD -- /directory/my-file.txt

Example 2: How can I reset or revert a file to a specific revision?

git reset <commit hash> <filename>

Example 3: git reset one file

git checkout HEAD -- my-file.txt

Example 4: revert unstaged changes git

git checkout -- .

Example 5: git reset specific file

git checkout c5f567 -- file1/to/restore file2/to/restore

Example 6: git revert commit for single file

git checkout <commit_hash> path/to/file