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.

How to create a .gitignore file
Within your git project repository create a file named .gitignore
% touch .gitignore
Add file names/extensions/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
*.class
# Log file
*.log
# Package Files
*.jar
*.war
*.ear
*.zip
*.tar.gz
Example:
% ls -a
.gitignore
2022070101_Local.log
release_1.2.0.jar
src
index.html
As you may see when I do a git status the log and jar files are not shown
% git status
.gitignore
src
index.html
This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Ventura 13.
Please support independent contributors like Code2care by donating a coffee.
Buy me a coffee!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!