Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (19.7k points)

git rm will remove entries from the staging area. This is a bit different from git reset HEAD which "unstages" files. By "unstage" I mean it reverts the staging area to what was there before we started modifying things.  git rm on the other hand just kicks the file off the stage entirely, so that it's not included in the next commit snapshot, thereby effectively deleting it.

By default, a git rm file will remove the file from the staging area entirely and also off your disk > (the working directory). To leave the file in the working directory, you can use git rm --cached.

But what exactly is the difference between git rm --cached asd and git reset head -- asd? 

closed

1 Answer

+7 votes
by (62.9k points)
selected by
 
Best answer
An example would help:
git rm --cached asdgit commit -m "the file asd is being removed from the repository"
versus
git reset HEAD -- asdgit commit -m "the file asd remains in the repository"
Note that if you haven't changed anything else, the second commit won't actually do anything.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...