Reputation: 731
I have a very basic github setup with a readme, a directory, and another directory inside it with an html file. On github I can only view the readme and the first folder but none of its contents, and I am getting this message
tc349 ryntc3$ git add *
tc349 ryntc3$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: week1 (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
I feel like if I am adding all to be staged that it should not be an issue. Any help?
Upvotes: 62
Views: 239584
Reputation: 1
To remove the submodule configuration for the frontend directory, please follow these steps:
Remove the submodule configuration:
bash Copy git rm --cached frontend If the .gitmodules file exists and is no longer needed, delete it:
bash Copy rm .gitmodules Re-add the frontend directory:
bash Copy git add frontend Commit the changes:
bash Copy git commit -m "Removed submodule configuration and added frontend directory" By following these steps, you can effectively remove the submodule configuration and reintegrate the frontend directory into your repository.
Upvotes: 0
Reputation: 373
In my case the problem was the subfolder that I was tying to push was a git folder itself
So I did the following
rm -rf .git
git rm --cached <subfolderName>
git add <folderName>/
git commit -m "Commit message"
git push -f origin <branchName>
Upvotes: 4
Reputation: 381
If it's a submodule you need to cd into it then use git add . && git commit -m 'Your message'
From there you can cd out and push to whichever branch you want.
Upvotes: 2
Reputation: 17442
Believe this occurs because you have a child repository "submodule" that has changes which have not been staged and committed.
Had a similar problem, where my IDE kept reporting uncommitted changes, and running the stage (git add .
) and commit (git commit -m "message"
) commands had no effect. Thinking about this in hindsight, it's probably because the child repository had the changes that needed to be staged and committed, not the parent repository.
cd
into the submodule (has a hidden folder named .git
) and execute the commands to stage (git add .
) and commit (git commit -m "Update child repo"
)cd ..
back to the parent repo, and execute the commands to stage (git add .
) and commit (git commit -m "Update parent repo"
)sudo rm -Rf .git
== DO NOT USE THIS COMMAND == it permanently deletes submodule repository history (the purpose of GIT)git add -A
=== Added untracked files, but didn't fix issueUpvotes: 1
Reputation: 3523
WARNING! THIS WILL DELETE THE ENTIRE GIT HISTORY FOR YOUR SUBMODULE. ONLY DO THIS IF YOU CREATED THE SUBMODULE BY ACCIDENT. CERTAINLY NOT WHAT YOU WANT TO DO IN MOST CASES.
In my situation, there was a sub-directory which had a .git
directory.
What I do is simply remove that .git
directory from my sub-directory.
Upvotes: 9
Reputation: 1527
WARNING! THIS WILL DELETE THE ENTIRE GIT HISTORY FOR YOUR SUBMODULE. ONLY DO THIS IF YOU CREATED THE SUBMODULE BY ACCIDENT. CERTAINLY NOT WHAT YOU WANT TO DO IN MOST CASES.
I think you have to go inside week1 folder and delete the .git folder:
sudo rm -Rf .git
then go back to top level folder and do:
git add .
then do a commit and push the code.
Upvotes: 43
Reputation: 21
This command may solve the problem :
git add -A
All the files and subdirectories will be added to be tracked.
Hope it helps
Upvotes: 2
Reputation: 81
I tried everything suggested on whole Stackoverflow. Nothing including -a or -am or anything helped.
If you are the same, do this.
So, the problem is, git thinks some of your subdirectory is sub-project in your root-project. At least, in my case it wasn't like that. It was just regular sub-directory. Not individual project.
Move that regular sub-directory which is not being pushed at some temporary location.
Remove the hidden .git folder from that directory.
cd
to the root directory.
git init
again.
git add .
again.
git commit -m "removed notPushableDirectory temporarily"
git push -f origin master
We will have to force it as the git will see the conflict between remote git and your local structure. Remember, we created this conflict. So, don't worry about forcing it.
Now, it will push that sub-directory as sub-directory and not as sub-module or sub-project inside your root-project.
Upvotes: 1
Reputation: 31
I was having the same problem. I ended up going into the subdirectory that was "not staged for commit" and adding, committing and pushing from there. after that, went up one level to master directory and was able to push correctly.
Upvotes: 3
Reputation: 368
For me, I had to commit the subdirectories which had .git
in it since both the parent and the subfolder have remotes to push to. And then commit and push the parent directory.
Upvotes: 2
Reputation: 2876
in my case, I needed a
git add files
git commit -am 'what I changed'
git push
the 'a' on the commit was needed.
Upvotes: 38
Reputation: 581
I kept receiving the same message no matter what i did.
To fix this, i removed .gitignore and i am not getting the Github changes not staged for commit message anymore. Before it would allow me to commit once when i ran git add . and then after it would bring up the same message.
Im not sure why the .gitignore file was causing a problem but i added on my local machine and most likely didn't sync it up properly.
Upvotes: 1
Reputation:
Is week1
a submodule?
Note the relevant part from the output of the git status
command:
(commit or discard the untracked or modified content in submodules)
Try cd week1
and issuing another git status
to see what changes you have made to the week1
submodule.
See http://git-scm.com/book/en/Git-Tools-Submodules for more information about how submodules work in Git.
Upvotes: 29