Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    I can't under stand the difference of 'git reset head <file>' and 'git rm --cached <file>. Could you explain it?
    – jeswang
    Commented Aug 14, 2013 at 0:39
  • 9
    @jeswang files are either 'known' to git (changes in them are being tracked.), or they are not 'versioned'. reset head undoes your current changes, but the file is still being monitored by git. rm --cached takes the file out of versioning, so git no longer checks it for changes (and also removes eventually indexed present changes, told to git by the prior add), but the changed file will be kept in your working copy, that is in you file folder on the HDD.
    – sjas
    Commented Aug 15, 2013 at 15:09
  • 4
    The difference is git reset HEAD <file> is temporary - the command will be applied to the next commit only, but git rm --cached <file> will unstage untill it gets added again with git add <file>. Also, git rm --cached <file> means if you push that branch to the remote, anyone pulling the branch will get the file ACTUALLY deleted from their folder.
    – DrewT
    Commented Aug 10, 2014 at 19:54
  • 2
    just what i searched git checkout -- <file> thanx ! Commented Aug 10, 2021 at 18:31