This happens when I forgot to create the
.gitignore file, resulting in the
target folder containing the class files got uploaded to git.
git rm -r --cached --ignore-unmatch target/* will send the command to delete the files.
-ris for recursion, so that any files and folders within the specified folder will be cleared.
--cachedparameter is so that it will keep the files on your local intact, since you most likely still need the files on your local, but not in your remote
--ignore-unmatchmakes sure the command will still succeed if there are some files not matched. This happens when you have some files not added yet.
Just like your
git add, executing
git rm does not make it happen until you commit. So a
git commit -m "delete file message" is still required to confirm the deletion.
git push origin main is required to push this change to your remote.
This only deletes the file, but the history of the files will still be there. So if you have uploaded sensitive information, like passwords or credit card information, these data can still be found in the history. For that case, a git filter-branch is required to clear the history.