Published : 2015-06-18

Remove a file from Git without removing it from the disk

In some cases you may need to remove a file from your repository without removing it from your disk (for instance the accidental addition of an Eclipse/VS/QTCreator project file).

To remove the offending file from git without removing it from the disk, type the following command:

git rm --cached fichier.proj

Same thing for a directory:

git rm --cached -r dossier_proj