How to filter specific files when submitting in Git.
To filter specific files when committing in Git, you can use a .gitignore file to specify which files or directories to ignore. Here are some steps to follow:
- Create a file named .gitignore and place it in the root directory of the Git repository.
- Open the .gitignore file and add the files, directories, or wildcard patterns to be ignored. Each item to be ignored should be on a separate line.
- Save and close the .gitignore file.
- The “git add .” command adds all files to the staging area, including the .gitignore file itself.
- Executing the git commit command will only commit changes to the .gitignore file and any other files that are not being ignored.
- Future submissions will automatically filter out files or directories specified in the .gitignore file.
It is important to note that even if a file has been added to version control and committed, Git will continue to track the file even if it is specified to be ignored in .gitignore. To completely ignore the file, you can use the git rm command to remove it from the repository.