![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the commonly used methods to auto-generate the .gitignore file?
The .gitignore file is a text file that tells Git which files or folders should be ignored while committing changes to the repository. This file lists the project files that we do not want Git to track for us.
Following are the two commonly used methods to auto−generate the .gitignore file −
Using the Github Site
The GitHub Site provides a collection of useful .gitignore templates for different technologies. The below screenshot shows a list of .gitignore templates provided by the site.
Let us say you are working on a Java project and would want to add a .gitignore file. All you have to do is −
Step 1 − Create an empty text file .gitignore and place it at the root of the project folder
Step 2 − Copy the contents of the .gitignore template for Java (that is shown below) into the file you have created.
Step 3 − Stage and commit the .gitignore file
Using Gitignore.io
Another recommended approach for creating .gitignore files is using the Gitignore.io tool.
As shown in the above screenshot, we can create a .gitignore file based an Operating System, IDE or Programming Language. Perform the following steps:
Enter the desired OS, IDE or Programming language and click on Create button. The tool will auto−generate the .gitignore file and render it in the browser. The following screenshot shows a .gitignore file created by the tool for a Golang project.
Create an empty text file in the project repository by the name .gitignore and copy the content generated by the tool
Index and commit the .gitignore file.