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
Command to ignore a single file
Command to ignore extension files
this commands ignores .c extension files.
Command to ignore subdirectories
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
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