Git Ignore

Git Ignore 1

There are some many junk files are created in our repository .some swap files are automatically created in our repo due to executions from IDE .so we should exclude these files in our repository .to ignore some files in git, git has a file name in every repository called .gitignore file .every time when git tracks change first it comes for .gitignore file and excludes the files and paths in it.

.gitignore file is used to exclude files, folders, subfolders, and type of file extension to be excluded in the staging area and in git commits

Open git ignore file

nano .gitignore

Command to ignore a single file

/path of file/ 
(example)
/bin/add.c

Command to ignore extension files

this commands ignores .c extension files.

*.c

Command to ignore subdirectories

/foldername

If the user executed a .c files in the git directory ad .exe files will be generated for output, so now user can able to ignore the .exe files adding to the repository

*.exe

If the user already added a file that needed to be ignored in future(before adding to the .gitignore) file, then those files will disappear after a file is added to .gitignore file and commit is made to a repository, older commits can have these ignored files in git

Default image
Vishal Devxo
Vishal Devxo is a DevOps engineer and a Backend developer, he spends all his time for creating good tutorials with better visuals and blogging, developed some projects based on Python-Django, some hacking modules and scripts in python