restore all files from git repo with their respective commit's their sha1 or date appended to their filename? -
Suppose i have a git repo that looks like this
commit # b97bd247a5d2530949c7acad0868e961c7777a28 Date: 2014 -04-24 Time: 07:43 file1.txt file2.txt commit # 4c1eb3b06dd4e51bf8541e67ec5dd8ad2744c695 Date: 2014-04-23 Time: 06:32 file1.txt I have all the files want to restore my ( both copies file1.exe ) and they like to restore a directory structure: file1_201404240743_b97bd247a5d2530949c7acad0868e961c7777a28.txt file2_201404240743_b97bd247a5d2530949c7acad0868e961c7777a28.txt file1_201404230632_4c1eb3b06dd4e51bf8541e67ec5dd8ad2744c695.txt < / Code>
"text">
Nothing has been made in GIT to do this, but doing so in a shell script Will be easy For example, suppose you have cd / tmp; MKDIR restoration; CD Restore and then for some commitments above: Export for # import_id in $ git rev-list ... GIT_DIR = / path / to / repo.git # Inserting the specs for the desired revs here is "$ $" for CDAT = $ (GIT show -s -pretty = format:% cd $ commit_id) $ $ git ls-tree --name ($ git ls-tree --name) Recover files from commit $ commit_id on cdate "echo only -r $ commit_id); GIT show $ {commit_id}: $ {file} & gt; $ {File} _ $ {cdate} _ $ {commit_id} done Note that this is not included between "name" and "extension" part: you file1 .txt_201404230623_b97bd247a5d2530949c7acad0868e961c7777a28 , for example. Redirection ( & gt; ... ) for files in the subdirectory will fail because the directory is not already present, too. To fix them (if they need fixing), use mkdir -p to create directories as needed, and to split the file names into "name" and "expansion" parts Use regular expression or some other similar technique, and enter commit-date $ cdate and commit-id $ commit_id .
Comments
Post a Comment