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 somewhere else.
If I run git status
it outputs the same:
nothing to commit (working directory clean)
If I create new branch and edit something, then same thing happens. This started happening when I needed to fix merge clashes. When I wanted to merge my one branch with master branch, I had to manually fix it and I needed my files to look exactly as in that branch overwriting master branch those same files. So I added those files and it let me merge it. But then no matter what I change it shows as there is nothing to commit.
What could be done here?
Here is another twist on it. My .gitignore file seemed to have been modified / corrupted so that a file I was ignoring
e.g.
got changed to this (Note now 2 separate lines)
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.
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.I had the same issue. The branch I was working on wasn't being tracked. The fix was:
This fixed it temporarily. To make the changes pertinently I:
I have faced the same issue with git while working with angular CLI 6.1.2. Angular CLI 6.1.2 automatically initializes .git folder when you create a new angular project using Angular CLI. So when I tried git status - it was not detecting the whole working directory.
I have just deleted the hidden .git folder from my angular working directory and then initialized git repository again with git init. And now, I can see all my files with git status.
Check the location whether it's the right location of the git project.
try removing the origin first before adding it again