Untrack files already added to git repository based on gitignore
In this article you will learn how to untrack files already added to git repository based on gitignore.
Step 1: Commit all your changes
Before proceeding, make sure all your changes are committed, including your .gitignore file.
Step 2: Remove everything from the repository
To clear your repo, use:
git rm -r --cached .
Step 3: Re add everything
git add .
Step 4: Commit
git commit -m "Untrack ignored files by .gitignore"
Your repository is clean,
Push the changes to your remote to see the changes effective there as well.