How To Change A File Back To A Previous Commit
Git
15/08/2022
Assume you unintentionally made changes to a file a few commits ago. To revert it to an earlier file version, i.e. commit, you can first list the version history of said file.
BASH
$ git log --oneline <file>
Once you know which version to revert your file back to, pick its commit hash (e.g. 902744c
) and run the following command:
BASH
$ git checkout <commit hash> -- <file>
Then stage and commit the changes.