How to Ignore Folder in Git using Gitignore?

By Hardik Savani November 5, 2023 Category : Git

In this short tutorial we will cover an how to ignore folder in git using gitignore. you will learn how to add folders to gitignore. we will help you to give example of git gitignore folder add. you'll learn git ignore add folder. follow bellow step for how to ignore folder in git.

In this example, I will show you how to create gitignore file and how to ignore a folder using gitignore file. there is a list of options where you can ignore folders and files. so let's see below one by one example and let's see.

Git Ignore Folder using .gitignore File

You can simple give path of files and ignore to push on git repository. I will add "database" and "data/json" specific folder will ignore for git pull and push. let's see example file.

.gitignore

database/

data/json

Example Ignore Files:

database/backup.sql

data/json/events.json

data/json/products.json

Git Ignore Files using .gitignore File

You can simple give path of files and ignore to push on git repository. I will add ".env", "data,json", "database/backup.sql" specific file will ignore for git pull and push. let's see example file.

.gitignore

.env

data.json

database/backup.sql

Example Ignore Files:

.env

data.json

database/backup.sql

Git Ignore Files with Wildcard Matches using .gitignore File

You can simple give path of files with extension and ignore to push on git repository. I will add "*.php" and "data/*.json" specific file extensions. will ignore for git pull and push. let's see example file.

.gitignore

*.php

data/*.json

Example Ignore Files:

index.php

event.php

data/events.json

data/products.json

I hope it can help you...

Tags :
Shares