I obliterated all my work and would prefer not to explain how.
The only thing I have left are the git objects. More then anything I would like to recover some of the loss packed Image files. From the size of the object files I can tell which ones they are. Is there a way to turn them back into usable files?
Using git-recover The simplest way to use git-recover is to use it in interactive mode: just run git recover -i . It will show you the first few lines of each "orphaned" file - those that were once git add ed to the repository but were never committed - and let you recover them (or not).
You can just use git reset 'commit id contains your deleted file' then merge and push it again. Show activity on this post. You should use git reset HEAD~ and then use git checkout -- <filename> to restore deleted files. You are assuming the deletion was made in previous commit, what if it was deleted long time ago.
You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.
The git fsck command checks the connectivity and validity of objects in the git repository. Using this command, users can confirm the integrity of the files in their repository and identify any corrupted objects.
if the git objects are still in the correct directory (.git/objects/xx/xxx…
) you can use git fsck --full
for git to discover them — it will probably list every object in your repository. now look for the ones labeled commit
and tag
, those are the ones you want to recover.
i would probably use a script which creates a branch for each commit object found (e.g. simply increnting numbers rescue-1
, rescue-2
, etc.). afterwards use gitk --all
to visualize all your branches and pick the top (most recent) one. create a new branch there rescued-master
.
checkout your new master branch and run git branch --no-merge
. you should get a list of branched off commits, not contained in master. you probably want to give them a new branch name too.
after you're done, delete all the numbered rescue-
branches.
hope that helps and gives a a starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With