Remove file from the repository but keep it locally

git rm --cached -r somedir

Will stage the deletion of the directory, but doesn’t touch anything on disk. This works also for a file, like:

git rm --cached somefile.ext

Afterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn’t try to add it back.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)