In this blog post, We are going to learn gitignore file tutorials with examples.
.gitignore is a file used by git tool to ignore the files and directories during committing source code changes to remote repository. Usually, ignore files or directors specific to local code bases or output of generated project running which are not required to commit to the remote repository. Each line in the file contains rules or patterns. Comment can be documented using # symbol.
This is an example for the gitignore file for node_module folder or directory of nodejs projects. In nodejs applications, the node_modules directory contains dependencies which are local to operating systems.
# application dependencies
# application npm log file
gitignore file can be created locally or globally global repository generation
These files are global git ignore files or directories which applies to all git repositories in your host. This is a single file for each operating system You can create a .gitignore_global on your user root of your operating system using Text Editor. Once the file is created with list of git ignore files and directories, You need to tell the global gitignore file to git using below command
git config --global core.excludesfile ~/.gitignore_global
local repository generation .gitignore file is created in each git repository which is local to git repository. you can create a local gitignore file using a text editor with all git ignore files and folders. gitignore location is placed in the root of the repository
Gitignore permissions issues will not be occured in windows, There are issues in Linux and Unix Operating Systems. core.fileMode will not track file permission changes For Local gitignore file permission changes
git config core.fileMode false
For Global gitignore file permission changes
git config --add --global core.filemode false
gitignore file is different for operating systems and language and frameworks. You can find here list of all available templates