Welcome to the Treehouse Community
Looking to learn something new?
Git command to move stagged files
In the example he uses git reset HEAD medals.html to remove the file from stagged. Is there any difference if I use this command : git rm --cached medals.html
Diem Pham12,277 Points
git reset HEAD --fileName will "reset" the index to the state it was before you started adding files / adding modifications to the index.
git rm will remove a file from the working directory and the index and when you commit, the file is removed from the tree as well.
git rm --cached removes the file from index alone and keeps it in your working copy.
I found the answer on stackoverflow - https://stackoverflow.com/questions/5798930/git-rm-cached-x-vs-git-reset-head-x
The main reason git reset is used is that to remove committed changes
- the changes may be more than a few lines of code
- a file that is lot more complex than the little html files in this lesson
in the case of large project knowing how to remove or reset a file back to the state before we committed changes in a life-saver.
I don't get the message to use git reset HEAD, it tells me instead to use git checkout <file>