This command will cause git to untrack your directory and all files under it without actually deleting them:
git rm -r --cached <your directory>
The -r
option causes the removal of all files under your directory.
The --cached
option causes the files to only be removed from git's index, not your working copy. By default git rm <file>
would delete <file>
.
If you need to have a tracked file (checked in), but do not want to track further changes of a file while keeping it in your local repository as well as in the remote repository, this can be done with:
git update-index --assume-unchanged path/to/file.txt
After that any changes to this file will no longer show up in git status
.
For a subdirectory called blah/
added to git, both of the following seem to work to ignore new files in blah/
. Added to .gitignore:
blah
blah/*
TL;DR to clean up your git repository and make sure ALL your ignored items are indeed ignored:
git rm -r --cached .
git add .
git commit -m "Clean up ignored files"
Note: you don't need to specify a directory, this way your are cleaning the entire remote repo.
To go further read this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With