Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialtobiastrinkler
Full Stack JavaScript Techdegree Student 16,538 PointsGit 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
3 Answers
Julie Pham
12,290 Pointsgit 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
danielperez
Full Stack JavaScript Techdegree Student 15,993 PointsThe 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.
Xavier Dep
2,179 PointsI don't get the message to use git reset HEAD, it tells me instead to use git checkout <file>