GIT Practical Reference
GIT Practical Reference
How to .gitignore
In Git, the .gitignore
file is used to specify which files and directories should be ignored by Git when tracking changes in your project.
Creating a .gitignore file
To create a .gitignore
file, you can use a text editor or run the following command in your project's root directory:
Ignore all files with a certain extension
To ignore all files with a specific extension, use the *.extension
pattern. For example, to ignore all .log
files, add the following line:
*.log
Ignore all files in a directory
To ignore all files in a specific directory, use the directory name followed by /*
. For example, to ignore all files in a directory named logs
, add:
logs/*
Ignore all .DS_Store files for mac
**/.DS_Store
Ignore specific files in a directory and its subdirectories
To ignore all files in a directory and its subdirectories, use the directory name followed by /**
. For example, to ignore all .tmp
files in the temp
directory and its subdirectories:
temp/**.tmp
Negate Patterns
You can negate patterns to include files or directories that would otherwise be ignored. For example, to ignore all .log
files except for important.log
, you can use:
*.log
!important.log