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
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Git,
- Fix [oh-my-zsh] Cant update: not a git repository
- [fix] fatal: pathspec index.html did not match any files error
- How to ignore files in git using .gitignore file
- Git Fix: fatal: refusing to merge unrelated histories Error
- Install GitHub Command Line Tool on Mac
- How to change directory in Git bash
- Get List of all local branches git command
- fix fatal: --local can only be used inside a git repository error
- [git] fatal: your current branch 'main' does not have any commits yet
- Git Revision Questions Before the Interview
- Change the default git branch name from master to main
- git command to remove/unstage files from staging area
- Remove git config at Local, Global or System Levels?
- [fix] fatal: this operation must be run in a work tree in git
- Clone a particular remote brach using git clone command
- How do I get a list of all branches in Git?
- How to check your installed version of Git
- Step-by-Step: How to delete a git branch from local as well as remote origin
- Git Commit - Author identity unknown, Please tell me who you are email
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- How to Rename a Git Local Branch Using the --move Option
- Perform an Empty Commit in Git without anything in Staging Area
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- GitHub: How to Search Code
- Rename git branch on Local and GitHub Remove using Command
More Posts:
- Best way to Convert Primitive long to int in Java with some Cautions - Java
- Android Disable EditText from Auto Focus on Activity load - Android
- How to force quit or kill Notepad++ Process - NotepadPlusPlus
- How to show Videos on SharePoint Page - SharePoint
- [fix] docker exec requires at least 2 arguments - Docker
- How to check of Updates on Microsoft Edge Browser on Mac (macOS) - MacOS
- Java JDBC NumberFormatException: For input string - Java
- Change Home Page on Safari for Mac (macOS) - MacOS