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 7572347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:54:14+00:00 2026-05-30T15:54:14+00:00

I made something very stupid. I made a commit using git commit (file edits

  • 0

I made something very stupid.
I made a commit using git commit (file edits + new files) (C).
Then I made amend last commit.
Then I deleted all files recursively (!) using git rm -r
Then I made another git commit (C).

A-B-C
    ↑
  master

Is there any way to undelete the files but keep the changes I had in my first commit? (C)
I’d rather do not go back to (B).
I tried git reset –soft head^, so then the git status lists files I deleted, then I did git checkout, but still no luck. I don’t even know if it’s possible.

  • 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-05-30T15:54:15+00:00Added an answer on May 30, 2026 at 3:54 pm

    Do yourself a favour and do not do git checkout <hash> like the other answer suggests and go into more problems.

    IF you have deleted file from your working directory and not committed the changes yet, do:

    git checkout -f
    

    CAUTION: commit uncommitted files before executing this command, otherwise you’re going to lose them all

    The deleted files should be back again.

    If not and if you can find the commit that you want ( C, etc. – your question is not clear ) from git reflog, just do git reset --hard <hash from reflog> and you should be all set.

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

Sidebar

Related Questions

I am trying to do something very simple: create a new branch. But I
I made a very simple spinlock using the Interlocked functions in Windows and tested
I must have done something very stupid which has caused the following situation. Basically
i think i'm missing something very trivial here. i made an ad-hoc provisioning profile,
I'm sure there's something very simple I'm doing wrong here, so I made these
I'm a completely new to C++ and I'm having a very stupid problem. I
How is randomness achieved with Math.random in javascript? I've made something that picks between
This is something that made me doubt for a while so I thought it
I have just done something without thinking it through. I have made a branch
Microsoft has made saving objects very easy with their LINQ to SQL mapping. However,

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.