Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:04:29+00:00 2026-06-08T08:04:29+00:00

I had to recover a few git bare repositories from a backup, and found

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:04:30+00:00Added an answer on June 8, 2026 at 8:04 am

    Of course, if you have any checkouts of these repos, the easiest thing to do is to just recover from those.


    refs just contains files with the SHA1 of commits that those names point to; refs/heads/master is probably all you need, containing just the SHA1 of the commit for HEAD. You didn’t lose any data (that’s all in objects), but it might be a bit tricky to find out the SHA1 of the commits you want.

    If you have the file logs/HEAD, the ref should be in there at the bottom (the first SHA1 being the parent of the most recent commit and the second being the id of it; there might be more if it’s a merge commit, not sure). For example, here’s the last line of one of my repos:

    4b2ef6873c3f4c7eaebca06fee4b95ffa9cf58c3 feb84419b6685b920f8a3d61a77e9508ba5dcfe1 Dougal Sutherland <dougal@gmail.com> 1342838724 -0400 pull: Fast-forward
    

    so the hash starting with feb84419b6 is the one I’d want. Unfortunately, I think these are only in non-bare checkouts.

    If you don’t have those logs, the commits are all in the objects directory. It’s somewhat likely to be a recently modified one, which you can get on Unix for example by ls -1t */* | head -10 from the objects directory; you can try a couple and see what happens. If you get from this, say

    04/718652eb1f03bb0594cc05665665b749b52a87
    

    then remove the / to get the hash you want to use:

    04718652eb1f03bb0594cc05665665b749b52a87
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a lot of local changes. I just accidentally did git merge another_branch
I have using VPS that had to be re-imaged. my DB was part of
I have: SQL Server 2008 Database Name: database1 I had taken backup from database1
Had to download Command Line Tools from Apple to get make to work, but
Had received a module from CCAVENUE and it was working fine with Magento 1.6.2...
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
I had a debate about macros and their readability. I think that in some
I had a question in MySQL, did it correctly. But the book code differs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.