Last active
April 9, 2021 18:01
-
-
Save technickle/e28a1c3ded5ed7141cc214f01fc55b4d to your computer and use it in GitHub Desktop.
Revisions
-
technickle revised this gist
Apr 9, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # this shell script extracts all prior versions of a file in a git repository # make sure to enable execute permissions on this file if your operating system # requires it: chmod +x extract-all-file-git-commits.sh # parameters: # - path-to-file (from root of repository) -
technickle renamed this gist
Apr 9, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
technickle created this gist
Apr 9, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ # this shell script extracts all prior versions of a file in a git repository # parameters: # - path-to-file (from root of repository) # - output directory # - output file extention # eg. ./extract-all-file-commits.sh "./public/data/vaccinations/locations.csv" "./output" "csv" # smarter things it could do: # auto-detect extension from first parameter #check to see if output directory exists; if not, make it [ ! -d "$2" ] && mkdir -p "$2" #generate the list of commits for the specified filespec and stick it in the temp directory git log --pretty=format:"%H %cI" --reverse -- $1 > /tmp/extract-all-file-commits.txt #iterate through the file in the temp folder and output the file from each commit with the timestamp as filename while IFS=" " read -r item1 item2; do git show "$item1:$1" > "$2/$item2.$3"; done < /tmp/extract-all-file-commits.txt