0 votes
1 view
in Devops and Agile by (14.6k points)

How to remove a file from the index ( = staging area = cache) without removing it from the file system?

1 Answer

0 votes
by (20.1k points)

Since you want to remove a file from the index without removing it from the file system, I would suggest you to use the following command: 

$ git rm --cached [file]

Even if you omit the --cached option, it will be deleted it from the working tree. I would also like to mention that git rm is slightly safer than git reset, because you'll be warned if the staged content doesn't match either the tip of the branch or the file on disk. (If it doesn't, you have to add --force.)

...