Last active
August 5, 2022 15:59
-
-
Save eddiemoya/5346242 to your computer and use it in GitHub Desktop.
Restores file that was deleted in a previous commit based on its last known state before it was removed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Git Unremove ## | |
# Adds an alias called "unrm" to retrieve a pile or path deleted at any point in the repositories history. | |
# Usage: | |
# git unrm [path] | |
# git unrm path/to/file | |
git config --global alias.unrm '!COMMIT=$(git log -1 --pretty=%h -- "$1"); git checkout $COMMIT^ -- "$1"; echo "File: $1, was restored from commit $COMMIT"; git show -s $COMMIT' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment