Skip to content

Instantly share code, notes, and snippets.

@guillermoroblesjr
Last active August 29, 2015 14:24
Show Gist options
  • Save guillermoroblesjr/976c0661a3c07d049a46 to your computer and use it in GitHub Desktop.
Save guillermoroblesjr/976c0661a3c07d049a46 to your computer and use it in GitHub Desktop.
Reverting a file(s) to a specific Git commit
# find the file w/path you want to revert
find <a-parent-directory-of-file> -name "<name-of-file>"
# get all commits (hashes) where changes were done to this specific file
git log --abbrev-commit --pretty=oneline <path-to-your-file>
# revert this file (while keeping changes in the history) to this hash
git checkout <hash> <path-to-your-file>
# do a 'git add' and 'git commit'
# view the commits on the file (all are still there, yours is the most recent)
git log --abbrev-commit --pretty=oneline <path-to-your-file>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment