I did a git filter-repo and now all files are deleted. VS code gitgraph is showing that the repo has no commits. Is there any way to restore my repo? My whole project got deleted and its a local repo so I don't have any backup. I have been working on it for months. Its killing me. PLEASE HELP. I'm desperate.
I have a commit-map file in the filter-repo folder in the .git with contents like this:
old new
2dcc8b30c4fb13d32f7b448c77a487de1a1d9bd5 0000000000000000000000000000000000000000
4e6915559685c96fe9dc336e1c929f129b603cbc 0000000000000000000000000000000000000000
8bf8d9d278523bf10d50b568eab1f8e5ac6cf8eb 0000000000000000000000000000000000000000
06a897ea4763c3f6034ccdd15e906580dda5f27b 0000000000000000000000000000000000000000
92e8933b223cd7e40bc80f9ac0a2853978bede3d 0000000000000000000000000000000000000000
0b7e2ade7c560078178cb66c0b3acd7d50b5fc10 0000000000000000000000000000000000000000
c296e3f6dd1cfcea8c3ec536c21d17112a9a0222 0000000000000000000000000000000000000000
8ce24d364c43023585109ef680dc2e4dadeeeff6 0000000000000000000000000000000000000000
e9614633a8463e3cdcf0a47206e0639a06aa7527 0000000000000000000000000000000000000000
66f3b8712aa57eaa396251dcc0f5f3285db5ff3b 0000000000000000000000000000000000000000
44442eace317b2b19063cc8c31ffe4a81d216ee7 0000000000000000000000000000000000000000
42877255047bf0376002b98173607a6a89bfab71 0000000000000000000000000000000000000000
54db7f7714302506a137c7b28bcb9a2bad7fc2b4 0000000000000000000000000000000000000000
0f3416c5c8fd3951d7e59a4d23db63f74b9383a3 0000000000000000000000000000000000000000
56379fdd472c102dd50691d9294d27da4b7c9a3d 0000000000000000000000000000000000000000
cc6bb41310efe3e5c2d0f58c956b3dcfd2b9e41a 0000000000000000000000000000000000000000
d7b1b929c943d923e91640b5bcdf49003c6f97cd 0000000000000000000000000000000000000000
f70375aae8340cccfb3c7db235e08464d9cfd1d8 0000000000000000000000000000000000000000
1dfe31b45b82aeb7ef514d81f26547736d60501a 0000000000000000000000000000000000000000
d19e2c4829a2c38c1a0c2adbe60e5a9ca70f7700 0000000000000000000000000000000000000000
7961c20ba12b49ef13996d34f5c4ac6038848418 0000000000000000000000000000000000000000
26ca13021b43c0b8b1b4e6a03948eb091ac6eb12 0000000000000000000000000000000000000000
f03d117ed04f449ae4f4ec1e61e895883acbe491 0000000000000000000000000000000000000000
f0d6ee7e4c778d28f65c864752f0e5cb80648fca 0000000000000000000000000000000000000000
5ce120582976dce9e8921c26adfdd7e5f23814c8 0000000000000000000000000000000000000000
818cd9397dbaa6278f0c33d9ce0ee5115c0c071b 0000000000000000000000000000000000000000
c4cd1317a269f9dc59ded0b9888754c6c205b711 0000000000000000000000000000000000000000
and a ref-map file with:
c4cd1317a269f9dc59ded0b9888754c6c205b711 0000000000000000000000000000000000000000 refs/heads/master
Is there any way I can restore. Its a disaster. I'm literally crying. PLEASE HELP
Edit: commands i used
D:\my_project>git filter-repo --force --subdirectory-filter back\
Parsed 27 commits
New history written in 0.53 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
Updating files: 100% (6161/6161), done.
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Completely finished after 9.45 seconds.
D:\my_project>git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
.vscode/
front/
nothing added to commit but untracked files present (use "git add" to track)
D:\my_project>git log
fatal: your current branch 'master' does not have any commits yet
c4cd1317a269f9dc59ded0b9888754c6c205b711
still reachable, say withgit show c4cd1317a269f9dc59ded0b9888754c6c205b711
? (If yes and it shows something meaningful, then you can set the master branch back bygit branch -f master c4cd1317a269f9dc59ded0b9888754c6c205b711
doing the same for the rest of the branches). 3) What does happen if you dogit show-ref
? – Calcifygit show-ref
does nothing.git show c4cd1317a269f9dc59ded0b9888754c6c205b711
returnsfatal: bad object c4cd1317a269f9dc59ded0b9888754c6c205b711
– Rattraygit show-ref
does nothing (otherwise it looks like an empty repo; OR git filter-repo does not retain old refs in a refs namespace similarly to git-filter-branch?). By the way, isgit reflog
working`? – Calcifygit reflog
returnsfatal: your current branch 'master' does not have any commits yet
– Rattraygit filter-repo
requires that you start with a clean clone of some existing repository, and then builds a new repository. Do not overwrite the old repository with the new one! (At least, not yet.) Make sure the new repository is what you want. Archive the old repository somewhere before switching to the new one. The new repository is not compatible with the old repository; do not attempt to use both. – Blaisdellgit-filter-repo
with some dummy arguments against it, and I still seem to be able to reconstruct the original repo: a lot of entries in the map files are not set to zeroes (don't know why yet), andgit show-ref
shows thatgit-filter-repo
created manyrefs/replaced/...
to recover from. (Also its help documentation suggests using--source
and--target
in order not to break the existing repository...) – Calcify.git/objects
represent something meaningful? (theinfo
andpack
directories (with .idx and .pack files inside), possibly a lot ofxx
directories that probably weren't cleaned up but still containing git objects) -- if so, then they possibly might be used to recover from (or at least to be backed up in order to pick data from), however at very low level. I'm out of ideas. – Calcify.git/objects
directory is "big enough", better back up/archive the.git
directory and put the backup in a very safe place. Git has some low-level commands listed here: git-scm.com/docs/git#_low_level_commands_plumbing that can be used to peek into the contents of the .git directory internals (but one more time: with caution!) and possibly reconstruct at least some blobs (files). If that directory is not "big" and your 28 commits are really gone... then sorry. – Calcifygit verify-pack -v
cannot parse.git/objects/pack/.....pack
reports:bad
. The only thing I guess you can do with that is going through each file and checking whether taking the restored content from the bundle would help you recovering your work (I saw some text files there that are clearly JSON or SVG, etc). Sorry, unfortunately this is where my "expertise" and help end... – Calcify.git/objects
, emitfind -type f | xargs -I{} file {}
to enumerate each file (usingfind
) and try to determine its type by content (usingfile
). Some of the files types are reported asASCII text
,Java source, ASCII text
, etc. For compressed stuff reported i.e. aszlib compressed data
you can use unix.stackexchange.com/questions/22834/… to decompress the blob (note is compressed data, not an archive). – Calcify.git/objects/XX
directories and simply use Quick View panel using Ctrl-Q to detect the blob content by your eyes. It would be tedious, but maybe those hints would let you recover as much as possible. – Calcify