Bash function to restore a deleted file in a Git repository
Add to .bashrc or .bashprofile
```
function gitundeletefile () {
if [ $# -eq 0 ]; then
echo "Usage: gitundelete_file <filepath>";
exit 1;
fi
git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"
}
```
Written by Rick Pearson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#