Best bet is to copy your folder. Delete the original. Clone the project from github, copy your new files into the new cloned folder, and then try again.
Double check your .gitignore file to make sure that the file is able to be seen by Git. Likewise, there is a file .git/info/exclude that 'excludes' files/directories from the project, just like a .gitignore file would.
Odd, but I fought with git all night to add a file. Turns out it was already added. Git wasn't picking up my changes, as the changes weren't being saved, as the file was inaccessible by my account, and my IDE wasn't reporting this over SSH.
In short, check to make sure you don't have it already added to the repository.
In my case the issue was enabled SafeCrLf option. I am on windows with tortoise git. After disabling the option adding the files was not an issue anymore.
I found myself in a similar situation as the poster:
If I call "git add .", and then "git status" and it keeps saying
"working directory clean" and has nothing to commit.
But I had a different solution than what's here. Since I came to this first, I hope to save others some time.
From the above answers and what I've seen elsewhere, the usual fixes to this problem are:
Ensure there are actually saved changes on the file in question
Ensure the file doesn't meet your exclude rules in .gitignore and .git/info/exclude
Ensure you're not trying to add an empty folder. Git won't track those. Standard solution is to place a blank file named .gitkeep as a placeholder so git will track the folder.
In my case, I had originally tried to create a git repo around an existing repo (not knowing it was there). I had removed the .git folder from this sub repo a while ago, but I didn't realize that it was too late, and git was already tracking it as a submodule. You can read more about how these behave and how to remove them here, but
the solution for me was to simply run git rm --cached path_to_submodule.
Make sure you have not changed the case of the folder name in Windows:
I had a similar problem where a folder called Setup controlled by Git and hosted on GitHub, all development was done on a Windows machine.
At some point I changed the folder to setup (lower case S). From that point on when I added new files to the setup folder they were stored in the setup folder and not the Setup folder, but I guess because I was developing on a Windows machine the existing Setup folder in git/github was not changed to setup.
The result was that I couldn't see all of the files in the setup in GitHub. I suspect that if I cloned the project on a *nix machine I would have seen two folders, Setup and setup.
So make sure you have not changed the case of the containing folder on a Windows machine, if you have then I'd suggest:
I searched around for a while and ended up finding out I had blocked off the SSH port which was what caused the git add command to stop working. I ended up changing origin using https with the following command: git remote set-url origin [url-to-git-repo]
I had this problem with the first program in the folder. I did "git add" then "git commit". "git status" gave the error described i.e. "nothing to commit, working directory clean"
I ended up deleting the .git file from the program folder. Then I did a new git init, git add and git commit and it worked.
It's impossible (for me) to add the first file to an empty repository cloned from GitHub. You need to follow the link README, that GitHub suggests to create. After you create your first file online, you can work normally with git.
Silly solution from me, but I thought that it wasn't adding and pushing new files because github.com wasn't showing the files I had just pushed. I had forgotten that the files I added were on a different branch. The files had push just fine. I had to switch from my master branch to the new branch in github to see them. Lost a few minutes on that one :)
I know this is a really old question, but I know it can happen to someone as well, turns out I was working with a file named AUX.JS and thi is a reserved file name for windows, this produced the following error
fatal: unable to stat 'src/hoc/Aux.js': No such file or directory
so you can either remove the file or rename it, then it will work.
Final conclusion, in addition to all other valid answers, if you are in a windows machine look out for the output of the 'git add' command, it can also provide additional information.
Had the same issue with a repo that I cloned from SiteGround Git to my mac. The freshly cloned repo had a list of changed files that git status said needed to be added to the commit, but trying to add or checkout any of them didn't do anything at all.
For some reason there were case changes in the filenames (e.g. .jpg -> .JPG). The solution was to simply git mv the filename the OS was using to the name git was using, e.g.:
I recently experienced this issue on my computer running Windows 7. I am using the git command window interface. The solution was to be very careful about the case sensitivity of the file and directory names when doing the git add. Although git would not complain when the case did not exactly match the case of the Windows file system file and directory names it also would not add the files. There would be nothing to commit. Once I typed the file names with the exactly correct case they would be added and listed under the changes to be committed as I intended.
I was having this issue on Visual Studio, what worked for me was:
1- Right click on the added file that is not being recognized by git.
2- Select "Add excluded file to Source Control"
I had a problem where files from one folder wont get added to the Github source control. To solve that I deleted the .git folder that was created under that folder.
The problem was, on Windows, in the index, the file was added in a case different from what was in the unstaged area. For example, in the index, the file was name xx.txt and in the unstaged area, the file was names Xx.txt.
Removed the file with the incorrect case from the index (xx.txt). Then, I have been able to add the file with the correct case (Xx.txt).
Issue
git would not add a changed file.
Using git bash, I had changed folder delimiting the folder name with the double quote.
ls displayed the folder contents correctly but git would not add changed files.
Solution
I used the single quote to delimit the folder name.
e.g.
CD "Folder Name"
git status
nothing to commit, working tree clean
CD ..
ls
'Folder Name'
CD 'Folder Name'
git status
modified: ModifiedFileName.bat
I have tried all the above but nothing was working. Later on, I ran my command prompt as an admin and retried all the stages i.e.
staging-> committing-> remote add -> pushing.
It worked like a magic. The changes were reflected in the desired remote repository.
I am still a beginner at git, and it was just a stupid mistake I made, long story in one sentence. I was not in a subfolder as @gaoagong reported, but the other way round, in a parent folder. Strange enough, I did not get the idea from that answer, instead, the idea came up when I tested git add --all, see the long story below.
Example in details.
Actual repo:
The Parent folder that I had opened mistakenly on parent level (vscode_git in my case):
I had cloned a repo, but I had a parent folder above this repo which I had opened instead, and then I tried adding a file of the subfolder's repo with git add 'd:\Stack Overflow\vscode_git\vscode-java\.github\ISSUE_TEMPLATE.md', which simply did nothing, no warning message, and the git status afterwards said:
nothing added to commit but untracked files present (use "git add" to track)
Running git add --all gave me the yellow notes:
warning: adding embedded git repository: vscode-java the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
git submodule add vscode-java
hint: If you added this path by mistake, you can remove it from the index with
git rm --cached vscode-java
See "git help submodule" for more information.git
To fix this, I reverted the git add --all with git rm --cached -r -f -- "d:\Stack Overflow\vscode_git\vscode-java" rm 'vscode-java':
Then, by simply opening the actual repo folder instead,
the git worked as expected again. Of course the ".git" folder of the parent folder could be deleted then:
You can remove recursively the git initialised repo $cd repo added $git rm -rf git
You can create a separate branch and link the submodules to the master branch The documentation on submodules is really useful Documentation [https://git-scm.com/book/en/v2/Git-Tools-Submodules]
Also see some solutions in [https://stackoverflow.com/questions/36236484/maintaining-a-git-repo-inside-another-git-repo]
I made another directory outside of the origin, I moved into that directory, then I cloned the existing git repo using the http://../../.git file as set out on the page in github.
Once it cloned the source (which had nothing more than a readme.md) I copied all the files from the old directory into the new one with
cp -rf ../../* .
Then I added again, and then commited and pushed those edits.
I had this issue today. Couldn't figure it out. Then I realised I was in a subfolder instead of the project root. So the resolution was to cd .. into the project root and try again.