Question

I was trying to make my .gitingore work (Link to the question :) ).

I have just done

git rm . -r --cached 

and now I have a whole list of deleted files when I enter:

git status -s 

Is this normal? Can i safetly commit all my changes?

Or maybe there is a way to undo this command?

PS: I was trying to understand what this command do but i've only found this: http://brianloomis.wordpress.com/2009/08/10/git-rm-r-cached/ And it's not so clear to me.

PS 2: OK :) To save my skin I've made a reset:

git reset HEAD *

The DELETED files went bye bye :) There are no longer visible in git status -s . But still is it safe to do the command:

git rm . -r --cached and then add and commit it? 
Was it helpful?

Solution

"safe"? What it does is empty the index and commit the deletion of those files, without removing them from the working tree (your disk)

That means all those files become un-tracked (private).

Usually, you don't commit after such a command. You reset (as you did).
That can force content drivers (like a smudge script) or other .gitattributes directives to be applied again on all files.

You can see that command used in the GitHub help page "Dealing with line endings".

git rm --cached -r .
# Remove everything from the index.

git reset --hard
# Write both the index and working directory from git's database.

Again, in this case: no commit, only a reset.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top