Logo
BlogToast.
HomeAll PostsCategoriesRandom
Sign in
Logo
BlogToast.

Discover stories, insights, and perspectives from writers around the world.

Explore

  • All posts
  • Categories
  • Random

Dashboard

  • Sign in
  • Sign up
  • Forgot password

Legal

  • Contact
  • Privacy policy
  • Terms of service

© 2026 BlogToast. All rights reserved.

Fix files being tracked even after adding to gitignore
Tutorials2 min read

Fix files being tracked even after adding to gitignore

N

N@rutO

September 18, 2024

Have you faced issue where you add a file or folder to .gitignore expecting that git will ignore it while adding to commit. But it is not ignored and more you try, more you fail. It is because prior to adding it to .gitignore, that file or folder is already been tracked. Ignoring the files that is already tracked will not work because it is stored in cache of your local git repository. So, It needs to be deleted from cache first and then stage the changes.

Follow these steps to untrack the gitignore files/folders:

  1. To stop tracking the file and not delete from the local use

    git rm --cached <filename>
  2. To untrack every files and directory in your .gitignore file

    git rm -r --cached .

    This will remove changes from staging.

  3. Now add untracked files

    git add .
  4. Then commit your changes

    git commit -m ".gitignore fixed"

There you go. You fixed the issue and files/folders are being ignored again.

Tags

git cache gitignore delete
Advertisement

Discussion (0)

Related Blogs

Explore similar articles

How to setup weak password in Ubuntu
Tutorials
2 min

How to setup weak password in Ubuntu

J

N@rutO

Sep 11

2 0
How to bypass internet connection and install Windows 11
Tutorials
4 min

How to bypass internet connection and install Windows 11

J

N@rutO

Dec 6

3 0