gitignore file will not untrack them -- they will remain tracked by Git . To untrack files, it is necessary to remove from the repository the tracked files listed in . gitignore file. Then re-add them and commit your changes.
The possible options are: traditional - Shows ignored files and directories, unless --untracked-files=all is specified, in which case individual files in ignored directories are displayed. no - Show no ignored files. matching - Shows ignored files and directories matching an ignore pattern.
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details. Each line in a gitignore file specifies a pattern.
For files that aren't tracked by Git, you can use a . gitignore or exclude file. For files that are tracked by Git, you can tell Git to stop tracking them and to ignore changes.
As I found in this post, .gitignore
only works for untracked files. If you added files to repository, you can:
git update-index --assume-unchanged <file>
or remove them from repository by
git rm --cached <file>
Edit
This article explains that too
I've had this issue come up as well, it's probably because you added your ignored directory/files to .gitignore after they were marked as "to be tracked" by GIT in an initial commit flow.
So you need to clear the git tracking cache like so:
git rm --cached -r [folder/file name]
A more detailed explanation can be read here: http://www.frontendjunkie.com/2014/12/stop-git-from-tracking-changes-to.html
The above command also removed the remnants of the folder/files from your remote GIT origin. So your GIT repos become clean.
Problem can be that this file is still in the git cache. To solve this problem needs to reset git cache.
git rm --cached <file>
Reset git cache. It is good command if you committed project when .gitignore file was not added.
git rm -r --cached .
git add .
git commit -m ".gitignore was fixed."
This surely works,
git rm --cached -r [folder/file name]
I assume you want not to add tmp directory (Visual Studio Platform)
1- add lines below to your local .gitignore file
## ignore tmp
/tmp/
./tmp/
3- backup and delete tmp Folder locally. (Backup somewhere else. eg desktop?)
4- Commit Changes to Local than Sync to Remote (eg. github).
After these steps your tmp directory wont be uploaded again.
after Make changes in .gitignore file. follow these simple steps
git rm -r --cached .
Run git add .
git commit -m "Commit message"
To check
git status
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