Git How To: Revert a single file
Example
- Revert a file to it’s 4 generation ancestor in its commit history and push the revert upstream.
- Though we don’t use git revert here, it works the same by creating a new commit based on the original commit we are reverting to:
- Revert a single file to a previous version
# get the commit id
git log -4 <filename>
# checkout the commit id
git checkout <commit-id> <filename>
# commit it anew
git commit
# push change to remote
git push