Remove commited files from git repository
by Ícaro Falcão
Sometimes we make mistakes, with programming it could be much more recurrent. After we commit unwanted changes and need to remove those files or folders from our repository (but not from the file system), we can do:
git rm --cached name_of_file.file_type
-cached option is what keeps the file in your file system, so if you want to delete the file from everywhere just remove this option.
-r option delete files recursively, that comes in handy when we want to remove a folder. Let's see the command again:
git rm --cached -r folder_name
But what if we commited sensitive data to our repository and we need to delete from the repository and past commits as well? In that case, github got us covered with a realy good article, check it out here.