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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:55:37+00:00 2026-05-17T16:55:37+00:00

1) I did git init in a folder 2) added some project files 3)

  • 0

1) I did git init in a folder

2) added some project files

3) I did git add * so it added recursively all files

4) I realised that I added a bunch of files I don’t want to be versioned, so I wanted to undo the add

5) git reset gives me the following error:

fatal: Failed to resolve 'HEAD' as a valid ref.

6) git status still shows all the added files

7) I tried git reset --hard HEAD and I got the following error:

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

8) git status still shows all the added files

What should I do at this point?

  • 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-17T16:55:38+00:00Added an answer on May 17, 2026 at 4:55 pm
    git rm [-r] --cache -- <file>…
    

    would be the right command to remove from the index the file you don’t want to commit.
    Any reset command won’t work, since you have to any commit yet in your newly created repository.

    From the git rm man page:

    --cached
    

    Use this option to unstage and remove paths only from the index.
    Working tree files, whether modified or not, will be left alone.

    -r
    

    Allow recursive removal when a leading directory name is given.

    <file>…
    

    Files to remove.
    Fileglobs (e.g. *.c) can be given to remove all matching files. If you want git to expand file glob characters, you may need to shell-escape them.
    A leading directory name (e.g. dir to remove dir/file1 and dir/file2) can be given to remove all files in the directory, and recursively all sub-directories, but this requires the -r option to be explicitly given.

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

Sidebar

Related Questions

I have a folder, which I use git init, then, I use git add
Did anyone try that feature and has some feedback? Or Does anyone know some
I am using git with capistrano. I initialized my project inside my folder on
Did you ever use Oracle auditing features on a production db? How did that
Did you know that : Map<Object,Object> m1 = new HashMap<Object, Object>(); Map<Object,Object> m2 =
Did anyone try to read programmatically an Alibre Design CAD file? I see that
I read the great git tutorial here, I'm unable to create directories. My folder
I did git checkout master . If I do git status it shows two
Did you ever have to choose between WISA or LAMP at the beginning of
Did you ever had a bug in your code, you could not resolve? I

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.