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

  • Home
  • SEARCH
  • 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 7888139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:45:29+00:00 2026-06-03T05:45:29+00:00

When I run ‘git checkout’, I also want to delete all additional files that

  • 0

When I run ‘git checkout’, I also want to delete all additional files that have been created after commit.

But I couldn’t find the way. Here is the thing I tested,

I created a directory test and made a file test/test.txt after I commit.

Then I run git add . and git checkout, but the new file and directory were not deleted.

Why the new files were still exist even though I put command git checkout as roll-back?

How can I go back to the stage completely?

Thank you for your time and reading my question.

  • 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-03T05:45:31+00:00Added an answer on June 3, 2026 at 5:45 am

    check out this thread: How do I revert all local changes in Git managed project to previous state?

    As Thr4wn notes, git reset --hard will solve your particular problem. However, as noted in the thread linked above, it will not remove untracked files: it removes your second file only because you previously ran git add .

    git clean -fd seems to be the solution that removes EVERYTHING you added after the commit (this means you will lose all those files).

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

Sidebar

Related Questions

1) Run Git Bash (C:\Program Files (x86)\Git\bin\sh.exe --login) $ ssh -v git@github.com OpenSSH_4.6p1, OpenSSL
I run multiple webpages that I have programming in .net. I am looking at
I run across this often enough that I figure there has to be a
I run a game and the running is done by hand, I have a
I run my sites all on InnoDB tables which is working really well so
I run some SAS queries monthly and they all take a fairly long time
I run a SaaS that allows free trials. Basically if you register you get
I run a fairly active student blog that uses this event calendar plugin to
I run a wordpress blog. I want my blog to be available only for
I run through millions of records and sometimes I have to debug using Console.WriteLine

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.