Reputation: 1564
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.
Upvotes: 78
Views: 109122
Reputation: 1
Maybe by mistake you have choosen th option Aassume Unchanged option
Please run this command
git update-index --no-assume-unchanged path/to/your/file
It worked for me after trying to solve this issue for 2 days
Upvotes: 0
Reputation: 530
This can happen as well when you change a file's casing (e.g. HelloWorld.txt
> helloworld.txt
). If this is the case for you, see How do I commit case-sensitive only filename changes in Git?
Upvotes: 0
Reputation: 2773
In my case I check my .gitignore_global, I found all my swift files ignored, I just removed the line *.swift and git recognized my ones.
Upvotes: 0
Reputation: 1885
Another reason to this problem may be the .gitignore_global
file.
In my case, it was automatically produced by Sourcetree
app while i was ignoring file. It was in my user path(/Users/user_name/.gitignore_global
).
Upvotes: 1
Reputation: 166833
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.
Upvotes: 121
Reputation: 1259
first check in your git repository to make sure that the file isn't there, sometimes capitalized letters can mess up a file being recognized but won't be recognized as a change, especially in a file extension like .JPG
(for some reason this happened to me although the file was saved the same as the others the extension was capitalized only on one and wouldn't appear on the site)
'if' this is the problem check 'show file name extensions' in relevant folder, rename file as something else with lower case extension, git add and commit and then rename it as originally wanted but keeping the lower case extension, because of the more obvious change it will be rewritten and not ignored
Upvotes: 0
Reputation: 1902
this happened to me when I was working on a branch I had just created called 'am'. I got on another dev station and couldn't see the file I added to the branch. In order to see the file I ran the following command
git checkout am
git branch --set-upstream-to=origin/am
git pull
after the pull all the changes came down
Upvotes: 0
Reputation: 3308
Quitting the GitHub app worked for me.
Symptoms:
My repo is on google file stream. I could only see modified files when running git status
but the GitHub app showed all changes.
Upvotes: -2
Reputation: 3569
some want to add an empty folder for some reasons If the content of the folder is empty, then there is no reason for git to mention it.
A convention says that you might want to add a file .keep
to it. which could also any other file.
Upvotes: 0
Reputation: 17333
I had the same problem (components/dashboard/js-dev/training/index.js
wasn't being tracked for some reason), so I did the following:
$ git check-ignore -v components/dashboard/js-dev/training/index.js
$ (gave me nothing)
$ git check-ignore -v components/dashboard/js-dev/training/
$ /Users/User/.config/git/ignore:23: components/dashboard/js-dev/training/
Anyways, I found this to be quite weird, so then I took a look at this file, /Users/User/.config/git/ignore
, and this is what it looked like:
(this is line 1)
# Automatically created by GitHub for Mac
# To make edits, delete these initial comments, or else your changes may be lost!
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
And it turns out that line 23 is in fact the one between .com.apple.timemachine.donotpresent
and # Directories potentially created on remote AFP share
, in other words, it was a completely empty line!
I tried removing all the extra newlines so my file looked like this:
# Automatically created by GitHub for Mac
# To make edits, delete these initial comments, or else your changes may be lost!
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
I run git status
, and I notice that it's now picking up components/dashboard/js-dev/training/
. I run git add components/dashboard/js-dev/training/
, and all works fine again.
Hope this helps someone - this issue got me stuck for an unnecessarily long amount of time.
Upvotes: 4
Reputation: 391
I encountered another cause for this. Probably very rare circumstances.
I copied my entire repository to another folder to work on it. Changes I made to a submodule just weren't being detected by git. Turned out that the .git file in the submodule folder contained an absolute file reference to the original copy. As soon as I corrected the file reference to point to my working copy all was well.
Upvotes: 0
Reputation: 662
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.
Upvotes: 19
Reputation: 175
If your project is a maven project, check if you changed the src file or the target file. That's what I did recently. With the file path reference being too long, I failed to notice the 'target' in the path. All good after 1 hr of agony.
Upvotes: 0
Reputation: 31
I also ran into this issue and it seems to be a problem with EGit plugin for Eclipse. Like @user1655478 said in previous comment, selecting the project in the projects view, performing a right click and selecting "Team > Advanced > No assume unchanged" fixed the problem for me.
Upvotes: 1
Reputation: 29
I had a similar issue and solved it.
I was getting this error message when running the git add
command:
The following paths are ignored by one of your .gitignore files:
<file>
Use -f if you really want to add them.
fatal: no files added
So I tried to force Git to solve the issue for me by adding a -f
to the git add
command. This would normally force Git to adjust the .gitignore
file and you will then be able to see the required change or problematic setting.
In my particular case there seemed to be some weird issue with the newline at the end of the .gitignore
file. Here how Git fixed the problem:
-RemoteSystemsTempFiles
+RemoteSystemsTempFiles
\ No newline at end of file
Upvotes: 2
Reputation: 7392
Extra note, I ran into this problem and found that changes to files weren't being added to commits. Nothing seemed to work, except Right clicking the project, and doing:
Team > Advanced > No assume unchanged
Upvotes: 1
Reputation: 301477
Apart from the the gitignore and other places to check for ignore patterns, check if you had run git update-index --assume-unchanged
or git update-index --skip-worktree
. If so, unset them.
Make sure that there is not some weirdness in the repo or parent of the file under concern whereby it has a .git
of its own.
Try doing a clone of your repo and see if you see the same in the cloned one. If so, try cloning onto a different machine / VM and check. That will give you some idea of what's going wrong where.
Upvotes: 8
Reputation: 83943
The file could also be listed in .git/info/exclude
, and there’s the option core.excludesfile
to watch, too.
Upvotes: 12