One of my users created a git annex repository a while ago and has since left the lab, and I think they messed it up badly.
It looks like all of the data is present in the annex directory, but there are no files in main directory, other than the .git folder. The master branch seems to be gone, and the only branch left is called git-annex.
git log gives the error "fatal: bad default revision 'HEAD'" when I first do git log, because the branch that I am on doesn't exist (the master branch). Changing to the git-annex branch works, but then I can't go back to the master branch because it doesn't exist.
git annex unannex doesn't seem to do anything. Is there any way to get the data back following this kind of mess up?
Thanks for your help
-Mike
If there are no branches, other than git-annex, then you do not have git history.
If it is really the old repository with deleted branches and not a newly created one, then there is a possibility, that the git history has not been fully deleted/garbage-collected yet (i.e. there are old objects and packs in
.git/objects
and.git/objects/pack
). It that case:Do not run git commands until you create a backup of the .git directory, because some usual git commands automatically launch
git gc --auto
, which removes some old unreachable objects (and maybe reflog entries).See if there are some reflogs of deleted branches or HEAD left in
.git/logs
. Reflogs will give you commit ids that branches’ tips pointed to. But usually reflogs are deleted with their branches.As the last resort, use
git fsck --dangling
to find objects, that may be the commits of deleted branches. See also other options ofgit fsck
command.Of course, all that is not necessary if you have a clone of the repo somewhere. Then just fetch the history from it.
Git history will give you the history of modifications in the repository, the content of not annexed files (that were stored directly in git) and the names of annexed files (represented as symlinks).
If all you need is just the contents of annexed files, then look at
.git/annex/objects
.But: if the repository was in direct mode, then
.git/annex/objects
may contain only old versions of files. The current versions of annexed files in direct mode are stored in the working directory, which is empty in your case.The git-annex branch contains just the location log of the content of annexed files, i.e. which git-annex repositories and when stored the contents.