I started getting this message. No matter what I edit and try to commit, it says there is nothing to commit. Looks like git does not see my working directory and looking som
Found what was wrong. I don't understand how, but .git
directory path somehow was changed to other path than I was working in. So then anything I changed was not checked, because git was checking in other place. I noticed it, when I reinitialized it and it showed that it reinitialized entirely different directory. When I cd ..
from my current directory and cd
to it back again and then reinitialized yet again, then it switched back to correct .git
directory and started seeing my changes.
For anyone seeing this problem, the simplest solution I found was to just "git clone" your repo and delete the old directory. This should set up your pathing correctly by default.
I just had this problem myself because I was in the wrong folder. I was nested 1 level in, so there were no git files to be found.
When I execute cd ..
to the correct directory, I was able to commit, as expected.
For people working in public open source projects, if you face this behaviour, it is most likely that the file you are editing is excluded from the git repository using .gitignore
. I faced the same behaviour, and after hours I found that the file I was making the change is excluded in .gitignore
because it is a settings file, and every one will have their own local version.
Here is another twist on it. My .gitignore file seemed to have been modified / corrupted so that a file I was ignoring
e.g.
/Project/Folder/StyleCop.cache
got changed to this (Note now 2 separate lines)
/Project/Folder
StyleCop.cache
so git was ignoring any files I added to the project and below.
Very weird, no idea how the .gitignore file was changed, but took me a while to spot. Once fixed, the hundreds of css and js files I added went in.
Don't try commiting / adding files. Just run the following 2 commands (:
git remote add origin http://xyzremotedir/xyzgitproject.git git push origin master