For Q10, one can also do git rm --cached <filepath> to remove the file from the git index and keep it in the working tree; which is the exact opposite of git add <filepath>. This will also work on filepaths that have been committed, which is especially helpful in the case of newly ignoring a previously committed file.
Also, conceptually git reset <filepath> is a wrong solution: it works only if you have not committed the addition of file (as you have said); git rm --cached <filepath> always work (though you need to remember that it removes the file only from future commits, and the file will be present in history).
Note that if you don't remember the command, git status would tell you how to do it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For Q10, one can also do
git rm --cached <filepath>
to remove the file from the git index and keep it in the working tree; which is the exact opposite ofgit add <filepath>
. This will also work on filepaths that have been committed, which is especially helpful in the case of newly ignoring a previously committed file.Also, conceptually
git reset <filepath>
is a wrong solution: it works only if you have not committed the addition of file (as you have said);git rm --cached <filepath>
always work (though you need to remember that it removes the file only from future commits, and the file will be present in history).Note that if you don't remember the command,
git status
would tell you how to do it.