I'm having issues where I can't add files to my repository.
I'm using GIT on windows, in Aptana Studio for some Ruby development.
I've managed to push a few files up to GitHub, but then after this, everything's stopped working. I have for example a new sub-folder in my master directory, with 2 ruby files inside. If I call "git add .", and then "git status" and it keeps saying "working directory clean" and has nothing to commit.
I've tried "git add folder/myfile.rb" and still nothing.
Anyone any idea's what I can try?
Git doesn't track folders, only files; you can't add an empty folder to a Git repo. However, you can put an empty file in that folder ( . gitignore or . blank are common file names) and add those files to the folder.
To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
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:
.gitignore
and .git/info/exclude
.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
git rm --cached path_to_submodule
.To add to the possible solutions for other users:
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:
setup-temp
git add -A
git commit -m "Whatever"
git add -A
git commit -m "Whatever"
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