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

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

Git - folder "refs" missing

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...