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 *.class # Log file *.log # Package Files *.jar *.war *.ear *.zip *.tar.gz
% 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
Have Questions? Post them here!
More Posts related to Git,
- [Fixed] Git Clone firstname.lastname@example.org: Permission denied (publickey) Could not read from remote repository Fatal error
- Github: How to Invite Collaborators
- Git Commit - Author identity unknown, Please tell me who you are email
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Get List of all local branches git command
- Git Revision Questions Before the Interview
- git fatal: Authentication failed error [fix]
- How to Install Git on Ubuntu Linux
- GitHub: How to Search Code
- How to change Git Default Author and Committer details in Eclipse
- How to check your installed version of Git
- Install GitHub Command Line Tool on Mac
- How to Merge Branch into Master Branch
- Perform an Empty Commit in Git without anything in Staging Area
- Git Fix: fatal: refusing to merge unrelated histories Error
- How to undo last Git Commit on Local Repository?
- git command to remove/unstage files from staging area
- Step-by-Step: Setting up Docker + Ubuntu Linux + Git + GitHub Tutorial
- Remove git config at Local, Global or System Levels?
- Fix [oh-my-zsh] Cant update: not a git repository
- Git Config Command - A Deep Dive
- 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 change directory in Git bash
- How to Change Eclipse Default Web Browser - Eclipse
- How to install tabnine on VS Code - HowTos
- How to Center Align Image in Bootstrap - CSS
- Connection Failed: 1130 PHP MySQL Error - MySQL
- Java SE 8 Update 301 available with various bug fixes and security improvements - Java
- Microsoft Teams Error code - 6 issue - Teams
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020 - Android
- Increase Android Emulator Timeout time - Android