Skip to content

Instantly share code, notes, and snippets.

@thomaskanzig
Last active August 28, 2022 11:35
Show Gist options
  • Save thomaskanzig/e17ba99065805525a6699b5112b83303 to your computer and use it in GitHub Desktop.
Save thomaskanzig/e17ba99065805525a6699b5112b83303 to your computer and use it in GitHub Desktop.
How to update .gitignore file

How to update .gitignore file

In some case, in the middle of our developlment, you have to add a new file or directory to the .gitignore file.
How do you do that?

Well, first of all make sure that the changed files in your project are saved in a commit. Then, add your file or directory to your .gitignore file.
Run these commands below to clear your repository cache and save again in a new commit:

git rm -r --cached . 
git add . 
git commit -m ".gitignore fix"

You will see now, in your editor (PHPStorm, Visual Studio, Sublime...) on the sidebar where are the structure of the project, the specific files that you added in the .gitignore, the text color have been changed.
This means it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment