restore file from git
This commit is contained in:
parent
5631b3cc4c
commit
9f035a609e
13
20_restore_file_from_git.py
Normal file
13
20_restore_file_from_git.py
Normal file
@ -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.
|
||||
"""
|
@ -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
|
||||
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
|
Loading…
Reference in New Issue
Block a user