github changes not staged for commit

GitGithubVersion ControlGit CommitGit Add

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

Have you tried

git add .

This recurses into sub-directories, whereas I don't think * does.

See here

Solution 2 - Git

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.

Solution 3 - Git

in my case, I needed a

 git add files
 git commit -am 'what I changed'
 git push

the 'a' on the commit was needed.

Solution 4 - Git

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.

Solution 5 - Git

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.

Solution 6 - Git

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.

Solution 7 - Git

In my case the problem was the subfolder that I was tying to push was a git folder itself

So I did the following

  1. Go inside the subfolder that you want to push and run this:
rm -rf .git
  1. Then run this:
 git rm --cached <subfolderName>
  1. Then come to main project folder and run this (make sure to add / after folder name)
    git add <folderName>/
    git commit -m "Commit message"
    git push -f origin <branchName>

Solution 8 - Git

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.

Solution 9 - Git

This command may solve the problem :

git add -A

All the files and subdirectories will be added to be tracked.

Hope it helps

Solution 10 - Git

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.

Solution 11 - Git

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.

Solution 12 - Git

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.

Solution 13 - Git

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.

Steps that fixed the issue
  1. 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")
  2. cd .. back to the parent repo, and execute the commands to stage (git add .) and commit (git commit -m "Update parent repo")
Advice that wasn't helpful
  • 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 issue

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRyan TiceView Question on Stackoverflow
Solution 1 - Gitg-eorgeView Answer on Stackoverflow
Solution 2 - GitWaleed AsenderView Answer on Stackoverflow
Solution 3 - Gitivo WelchView Answer on Stackoverflow
Solution 4 - Gituser212218View Answer on Stackoverflow
Solution 5 - GitMarvin WView Answer on Stackoverflow
Solution 6 - GitChrisView Answer on Stackoverflow
Solution 7 - GitYeshiView Answer on Stackoverflow
Solution 8 - GitapebeastView Answer on Stackoverflow
Solution 9 - GitBelachkar AliView Answer on Stackoverflow
Solution 10 - GitAustin ReidView Answer on Stackoverflow
Solution 11 - GitGoku NymbusView Answer on Stackoverflow
Solution 12 - GitcreamCheeseCoderView Answer on Stackoverflow
Solution 13 - Gittim-montagueView Answer on Stackoverflow