Icon

How to Create a .gitignore File in GitHub

Learn how to quickly create and commit a .gitignore file directly within a GitHub repository using the web interface.

By Matt

This guide explains how to create and commit a .gitignore file directly from the GitHub web interface. Adding this file ensures that unwanted files or directories are excluded from your version control tracking.

This workflow applies to software developers and open-source contributors who need to manage ignored files in a GitHub repository without using the local command line.

Ensure you are signed in to your GitHub account before beginning.

1
From your GitHub dashboard, select your target repository.
Step #1: From your GitHub dashboard, select your target repository.
2
Click Add file and select Create new file from the dropdown menu.
Step #2: Click Add file and select Create new file from the dropdown menu.
3
Type .gitignore as the file name and add your specific ignore rules into the main text editor.
Step #3: Type .gitignore as the file name and add your specific ignore rules into the main text editor.
4
Click Commit changes... in the top right corner.
Step #4: Click Commit changes... in the top right corner.
5
Enter a clear commit message and an optional extended description in the modal that appears.
Step #5: Enter a clear commit message and an optional extended description in the modal that appears.
6
Click Propose changes to finalize and save your new file to the repository.
Step #6: Click Propose changes to finalize and save your new file to the repository.

Term

Definition

Repository

A central location on GitHub where your project files, history, and collaborations are stored.

.gitignore

A configuration file that specifies which files or directories Git should intentionally leave untracked.

Commit

A saved record of changes made to the files within your version control system.