add file in gitignore which already in remote code example Example 1: gitigore rm cache git rm -r --cached . Example 2: apply gitignore after commit git rm --cached $file