Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I had to recover a few git bare repositories from a backup, and found out that git (I am using msysgit on wondows XP) did not recognise the repo as such. After some investigation, I found the problem seems to be that the folder "refs" was missing, together with the subfolders "heads" and "remotes". I also do not have the file "heads/master". Is there any way I can re-create it? I really need to recover the data in these folders.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
362 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you lost all your references (refs folder), but don't lose any actual data you can find all possible last commits by finding dangling commits (i.e commits which are not referenced by other commits as parents)

You can do it with the help of this command

git fsck --lost-found

This lists all dangling commits (and probably some other useful information). Use

git log SHA1SUM

to investigate further. Also it is a good idea to run

git fsck

to make sure that only referenced where lost.

UPD: Also refs can be located in packed-refs file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...