How to ignore files in git using .gitignore file

Git •gitignore file example

None of us will like to commit and add intermediate files to git repositories such as log and temp files, in order to not track specific files in your git repository you can make use of the gitignore.

.gitignore - Git will not track files that are specified in this file.

How to create a .gitignore file

Within your git project repository create a file named .gitignore

% touch .gitignore

Add file names/extenstions/regex to remove/ignore files

Any line that starts with as # hash or pound sign is a command and will be ignored!

Example: For Java Project:
# Compiled class file

# Log file

# Package Files
% ls -a

As you may see when I do a git status the log and jar files are not shown

% git status

Have Questions? Post them here!

Topics Coverage:

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram