Git is used for a lot of different projects. These projects may provide different types of files. Some times some of those files should not be committed into the repository. For example, after running a python application pyc files are created as compiled python files. Committing them are unnecessary.
Git Ignore File
To ignore files the patterns should be defined in a file named .gitignore
file. .gitignore
file by default resides in the root of the repository but can be used in subdirectories too.
$ echo "*.pyc" > .gitignore
$ cat .gitignore
*.pyc
$ echo "*.tmp" >> .gitignore
$ cat .gitignore
*.pyc
*.tmp
*.pyc
means any file ends with pyc extension- Each line for one entry
$ cat .gitignore
*.pyc
#temp files
*.tmp
#
is used as comment and no effect on files those will be ignored
$ cat .gitignore
/build
/build
directory is completely ignored
$ cat .gitignore
/build/*.out
- All files in
/build
directory with extension.out