Skip to content

Instantly share code, notes, and snippets.

@mohokh67
Last active October 28, 2025 20:13
Show Gist options
  • Select an option

  • Save mohokh67/c363e095adc8beb26b1fe7557bf9f289 to your computer and use it in GitHub Desktop.

Select an option

Save mohokh67/c363e095adc8beb26b1fe7557bf9f289 to your computer and use it in GitHub Desktop.
Fix the .gitignore and untrack files which are already added

Untrack files which are already added in gitignore file

  1. Commit all your changes

  2. Remove everything from the repository cache. Go to your repo directory and run this command.

git rm -r --cached .

It will only clear the cache. Your files and git history will stay.

  1. Re add everything
git add .
  1. Commit the fix
git commit -m 'fix .gitignore'

Sit back and relax. It'd done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment