.gitignore file tutorials with ignoring directory examples

gitignore file tutorials with ignoring directory examples

In this blog post, We are going to learn gitignore file tutorials with examples.

You can check my previous post on

.gitignore file example

.gitignore is a file used by the git tool to ignore the files and directories during committing source code changes to the remote repository.

Usually, ignore files or directors specific to local codebases 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 the # 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 that are local to operating systems.

.gitignore file  
# application dependencies  
# application npm log file  

How to Create a gitignore 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.

It is a single file for each operating system. You can create a .gitignore_global on the user root of your operating system using Text Editor. Once the file is created with a list of git ignore files and directories, You need to tell the global gitignore file to git using the below command.

git config --global core.excludesfile ~/.gitignore_global  

local repository generation .gitignore file is created in each git repository which is local to the 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

How to change git ignore file permission?

Gitignore permissions issues will not have occurred 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

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.