Ritik singla
Ritik singla

Reputation: 1

how to remove a directory or files in git bash to unstage them

I am checking status of me repo using " git status ". but it shows that i used to changes to be committed , here the commands are :

~/udacity-git-course/new-git-project (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   webpage.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        course-git-blog-project/
        npm-debug.log

then i used the command

$ git rm --cached <webpage.html>...

but it shows

fatal: No pathspec was given.

Which files should I remove? I don't know how to correct it and resolve it.

Upvotes: 0

Views: 710

Answers (1)

torek
torek

Reputation: 489293

First, let me put in this note: there's nothing wrong with having "changes to be committed". This is just about the actions you took afterward.


This line:

  (use "git rm --cached <file>..." to unstage)

is using angle brackets < and > to indicate that the word file is a placeholder. The angle brackets themselves must also be deleted when you enter the command. Furthermore, the three dots are meta-text meaning "repeat as needed". So, instead of:

git rm --cached <webpage.html>...

you were supposed to run:

git rm --cached webpage.html

(note lack of angle brackets and lack of three dots).

What happened here is that your shell "ate" the words webpage.html and ... and did I/O redirection. That is, you ran:1

<webpage.html >... git rm --cached

so that git rm's standard input came from file webpage.html and its standard output went to (new) file .... This will have left you with an extra file named ... that will now be reported as an untracked file; you will need to remove that with:

rm ...

(note no angle brackets and no git prefix and so on).

You should work through a tutorial on the use of your shell (which appears to be bash, sh, or similar).


1I/O redirections can be placed anywhere along the command, though it's typical for humans to put them at the right edge. That is, we tend to see:

generate-output --long >outfile

rather than:

>outfile generate-output --long

or the even weirder-looking:

generate-output >outfile --long

but all three perform the same action.

Upvotes: 2

Related Questions