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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:14:46+00:00 2026-05-28T19:14:46+00:00

By mistake I rm -rf a directory in my git repository. The changes are

  • 0

By mistake I rm -rf a directory in my git repository. The changes are not commited and I wanted to revert this change and go back to my last git commit.

# On branch release-1
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    dir/file1
#       [....]

As the files were deleted I was nit able to do git checkout -- <file> so I did git checkout -- instead, but this did not work.

Therefore I took a shortcut: stashed the changes

$  git stash
Saved working directory and index state WIP on release-1: d2dbff3 removed the CVS $Id lines
Checking out files: 100% (394/394), done.
HEAD is now at d2dbff3 removed the CVS $Id lines

And now is all OK.

I have the impression that stashing is a bit of brute force approach. Is it possible to do a checkout of the current branch (the whole one without giving any file) discarding any change?

  • 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-28T19:14:47+00:00Added an answer on May 28, 2026 at 7:14 pm

    In the short term, you can use git stash drop to get the superfluous entry out of your stash. In the future, you can use git checkout HEAD -- dir to get the head commit version of dir.

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

Sidebar

Related Questions

I changed the folder permission of my Home directory by mistake and it is
I did a mistake importing in an import to some SubVersion repository, and I
I seem to make this mistake every time I set up a new development
We are using Git and our workflow consists of a 'dev' and 'master' branch
I made the mistake of creating a Subversion repository without the usual trunk ,
I saw this in some header file in the framework directory: @interface NSCharacterSet :
I have made this mistake several times, and found myself referencing This Post every
Let's say I make a mistake in my first push to a remote Git
I found introducing a directory values-notlong-ldpi did not work out for me Solved it:
I have a Git repository on my local machine that I cloned from my

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.