I had created a new repository in GitHub and forgot to add the .gitignore file to ignore all my Visual Studio and debugging files. However, I did not realize it until after I created the first commit.
These are the steps to apply the gitignore file later:
- Create a .gitignore file in the root of your local repository. Run this command. This removes everything from the index:
git rm -r --cached .
- Re-add all files. Now the files and folders from gitignore are ignored.
git add .
- Then commit the changes again and push it to your GitHub repository
git commit -m ".gitignore is now working" git push