Adding .gitignore to a Git project

You are here

Having files that you don't need to commit but are important to your workflow on a project are 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 and one that I always have is a temp directory where I can store information or data that is not necessary to the Git master or a remote repositories.

The way to get around Git complaining about these files is use .gitignore what it does it allows the developer to state what directories or files that are not to be seen by Git to add or commit to the repository. The code below allows 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"

The attached file is what I add to all my Git repositories for it to work I remove <tmp> and add the .gitignore file to the root of the directory where the Git repository is.



225 bytes