Skip to main content

Adding .gitignore to a Git project

Member for

2 years 2 months
Submitted by admin on

Having files that you don't need to commit but are essential to your workflow on a project is always an issue. An example that keeps cropping up is the SCSS caches when you theme a website or your IDE leaves files in the root directory of a project. I always have a temp directory to store information or data that is not necessary to GIT or remote repositories.

The way to get around GIT complaining about these files is to use .gitignore what it does. It allows the developer to state what directories or files are not to be seen by Git to add or commit to the repository. The code below will enable you to add the .gitignore to an existing repository or one that you have created from scratch.

~$ git rm -r --cached .
~$ git add .gitignore
~$ git commit -m "fixing .gitignore"