Skip to content

Instantly share code, notes, and snippets.

@jkereako
Last active February 4, 2018 04:03
Show Gist options
  • Save jkereako/39a0f97eb6268ac88807 to your computer and use it in GitHub Desktop.
Save jkereako/39a0f97eb6268ac88807 to your computer and use it in GitHub Desktop.
Restore files in Git
# `git clean` removes all untracked files and `git checkout` clears all unstaged changes.
# see: http://stackoverflow.com/questions/52704/how-do-you-discard-unstaged-changes-in-git#12184274
git clean -df
git checkout -- .
# @see: http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo#4332209
# Restore all deleted files in Git
git ls-files -d | xargs git checkout --
# Revert all local changes to the last commit
git ls-files -m | xargs git checkout --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment