I would like to add to the accepted answer of @bdonlan.
DON'T USE THIS ANSWER TO REMOVE FILE(S) THAT EXISTS ON REMOTE.
git rm --cached filename
What the answer is supposed to do?
It is supposed to remove some files from the local staged area that you have mistakenly committed in some previous commit(s).
- And have not pushed to the remote.
- And if pushed on remote, others don't care about those changes.
It moves files from Tracked 𝐭𝐨 Untracked state by that what I mean is, it deletes the files and adds them again.
So, git doesn't know about them anymore.
What could go wrong?
On remote, there is 𝐧𝐨 such thing as an 𝐮𝐧𝐭𝐫𝐚𝐜𝐤𝐞𝐝 𝐬𝐭𝐚𝐭𝐞, there is 𝐨𝐧𝐥𝐲 𝐭𝐫𝐚𝐜𝐤𝐞𝐝 𝐬𝐭𝐚𝐭𝐞 and that results in havoc.
Why?
When collaborating with the team, if you 𝐩𝐮𝐬𝐡 such changes up to remote it will delete those changes on remote and all the team who takes a 𝐩𝐮𝐥𝐥 from 𝐫𝐞𝐦𝐨𝐭𝐞 𝐰𝐢𝐥𝐥 𝐜𝐚𝐮𝐬𝐞 𝐝𝐞𝐥𝐞𝐭𝐢𝐨𝐧 𝐨𝐟 𝐭𝐡𝐨𝐬𝐞 𝐟𝐢𝐥𝐞𝐬 𝐰𝐡𝐢𝐜𝐡 𝐲𝐨𝐮 𝐡𝐚𝐯𝐞 𝐣𝐮𝐬𝐭 𝐫𝐞𝐦𝐨𝐯𝐞𝐝 𝐣𝐮𝐬𝐭 𝐟𝐫𝐨𝐦 𝐬𝐭𝐚𝐠𝐞𝐝.
Summary: You removed files from staged and then pushed them will result in the deletion of files on the collaborating team's local repository as well (𝘸𝘩𝘪𝘭𝘦 𝘺𝘰𝘶 𝘩𝘢𝘷𝘦 𝘵𝘩𝘰𝘴𝘦 𝘧𝘪𝘭𝘦𝘴 𝘢𝘷𝘢𝘪𝘭𝘢𝘣𝘭𝘦 𝘪𝘯 𝘵𝘩𝘦 𝘶𝘯𝘵𝘳𝘢𝘤𝘬𝘦𝘥 𝘴𝘵𝘢𝘨𝘦, 𝘧𝘰𝘳 𝘢𝘭𝘭 𝘵𝘦𝘢𝘮𝘴 𝘪𝘵 will be 𝘨𝘰𝘯𝘦. )