diff --git a/20_restore_file_from_git.py b/20_restore_file_from_git.py new file mode 100644 index 0000000..f692d9d --- /dev/null +++ b/20_restore_file_from_git.py @@ -0,0 +1,13 @@ +from subprocess import check_output, call + + +file_name = str(raw_input('Enter the file name: ')) +commit = check_output(["git", "rev-list", "-n", "1", "HEAD", "--", file_name]) +print str(commit).rstrip() +call(["git", "checkout", str(commit).rstrip()+"~1", file_name]) + + +""" +After entering a filename, this script searches your Git history for that file. +If the file exists, then it will restore it. +""" diff --git a/readme.md b/readme.md index 894c746..ee46cd8 100644 --- a/readme.md +++ b/readme.md @@ -17,4 +17,6 @@ 1. **15_check_my_environment.py**: Pass in a config file based on your environment. 1. **16_jinja_quick_load.py**: Render a quick Jinja2 template 1. **17_rewrite_git_history.md**: Backdating/Rewriting Git history (use at your own risk) -1. **18_zipper.py**: Zip contents of a directory, adding a timestamp to the filename \ No newline at end of file +1. **18_zipper.py**: Zip contents of a directory, adding a timestamp to the filename +1. **19_tsv-to-csv.py**: Convert TSV to CSV +1. **20_restore_file_from_git.py**: Restore file from Git History \ No newline at end of file