How to create git ignore file and what is the use of this gitignore file?

January 02, 2015 - 16:09

Ignoring files:From time to time there are files you don't want git to track. There are a few methods of telling git what files to ignore. In which .gitignore file method is one of the popular method

  
    # Files to be ignored by Git

    # Ignore configuration files that may contain sensitive information.
    sites/*/settings*.php

    # Ignore paths that contain user-generated content.
    sites/*/files
    sites/*/private 

This is a code written in one site where they mentioned the files which they want to ignore. Here they mentioned settings.php and the user changing files which is not needed to add in the git repository since it is a changeable

If you create a file in your repository named .gitignore, git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. So once the repository is created you have to add the .gitignore file or else you have to remove the files which you added before you adding the gitignore file

This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository. Sometimes an empty .gitignore file is used as a placeholder for an empty path

Post your comments / questions