diff options
author | 2013-01-25 13:29:57 +0000 | |
---|---|---|
committer | 2013-01-25 13:29:57 +0000 | |
commit | af99b8ea8178d68b5ae8d110858f81b950e13656 (patch) | |
tree | 1af5baa8e5e55e75d4484781051dd4e3bfd4c3e0 /doc | |
parent | 3aad66cab7c0228d20d9e4258be50ac9a8db3c8a (diff) |
Diffstat (limited to 'doc')
-rw-r--r-- | doc/forum/archaeology_of_deleted_files.mdwn | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/forum/archaeology_of_deleted_files.mdwn b/doc/forum/archaeology_of_deleted_files.mdwn new file mode 100644 index 000000000..5705dc119 --- /dev/null +++ b/doc/forum/archaeology_of_deleted_files.mdwn @@ -0,0 +1,36 @@ +Earlier this week, I somehow lost a ton of files from my annex -- by switching on the command line from indirect to direct mode while the assistant was running, I think. I'm not sure. + +Anyway, by "lost" I mean "lost the symlinks to," because git-annex defaults to keeping content around till you tell it otherwise. So I still had the content in the repos on my two backup drives. All I needed was the symlinks back. + +But how to figure out exactly what I lost and get it back? + +I found that out here: + +http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo + +Here's a magical formula you can use to find every single file deletion in the history of your repo: + +git log --diff-filter=D --summary + +That will give you every commit that deleted things, and what was deleted. + +To bring back all the files deleted in a given commit, where COMMITHASH is the commit hash, use this command: + +git checkout COMMITHASH^1 -- . + +to bring back only a specific file: + +git checkout COMMITHASH^1 -- path/to/file.txt + +to bring back only a subdirectory: + +git checkout COMMITHASH^1 -- sub/directory + +that will bring them back into the staging area. You can see which ones just reappeared by typing: + +git status + +then you can actually make the restore permanent by typing: + +git commit -m "I just resurrected some files" + |