Updating .gitignore
Last Updated: March 19, 2024
You committed a file or files to git and pushed it up to GitHub. Not you. But yes, you. Let's fix that.
- Start by updating your
.gitignore
file and put the file or directory you want to ignore.
## You don't need to commit this!!!
node_modules
- Commit the newly updated
.gitignore
file.
git add .
git commit -m ".gitignore updated"
- Next, you want to remove all files uploaded that should of been ignored. To remove the cache in your repository run this command:
git rm -r --cached .
- Commit the changes to your that now has removed all files and directories in your
.gitignore
and push them to the repository.
git add .
git commit -m "files removed from .gitignore"
There you go. Just remember to put those file and directory names in .gitignore
next time. You won't forget, I'm sure.