I have a file called "style.css" and git is not detecting it. It doesn't detect it if I delete it either, but it does detect if I change the name of the file. But I need it with that name. The file is not in the .gitignore file. This is driving me crazy!
I would appreciate some help.
Some times, even if you haven't added some files to the repository, git seems to monitor them even after you add them to the . gitignore file. This is a caching issue that can occur and to fix it, you need to clear your cache.
gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.
-f, --force Allow adding otherwise ignored files. This only works for me using wildcards, using git 1.9. 5 on Windows, even after trying --no--assume-unchanged. "git add - f <filename>" does nothing, but "git add -f *" works.
Use git check-ignore
command to debug your gitignore file (exclude files).
In example:
$ git check-ignore -v config.php .gitignore:2:src config.php
The above output details about the matching pattern (if any) for each given pathname (including line).
So maybe your file extension is not ignored, but the whole directory.
The returned format is:
<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
Or use the following command to print your .gitignore
in user and repo folder:
cat ~/.gitignore $(git rev-parse --show-toplevel)/.gitignore $(git rev-parse --show-toplevel)/.git/info/exclude
Alternatively use git add -f <path/file>
which allows adding otherwise ignored files.
See: man gitignore
, man git-check-ignore
for more details.
Another note, probably a rare case but I had this problem. I moved some files that were already tied to a repo from one directory to another, copy/paste style.
Along with it came the .git folder, which prevented git from detecting the folder.
So my folder structure was this, with git not detecting Folder 2 even though the repo was set for Original Project 1:
--Original Project 1 --.git --Folder 1 --Folder 2 --.git --Many other files/folders
Deleting the child .git folder solved my problem.
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