To make Git ignore a folder, you need to add it to your .gitignore file. The exact steps depend on whether Git is already tracking that folder.

Case 1: The Folder Has Not Been Tracked Yet
- Open or create a file named
.gitignorein the root directory of your project. - Add the folder name with a trailing forward slash (
/) on a new line:
# Ignore a folder anywhere in the project
folder_name/
# Or, ignore a folder ONLY at the root level of your project
/folder_name/Case 2: The Folder Is Already Tracked
If you previously committed the folder, simply adding it to .gitignore won’t stop Git from tracking it — you must clear it from Git’s index first.
- Open your terminal at the project root.
- Untrack the folder. The
--cachedflag ensures the folder stays safe on your hard drive and is only removed from Git’s tracking:
git rm -r --cached folder_name/- Add
folder_name/to your.gitignorefile. - Commit the changes:
git add .gitignore
git commit -m "Stop tracking folder_name"