Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git won't add modified file

Tags:

git

git-add

No idea why this is happening:

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:   file (modified content)  no changes added to commit (use "git add" and/or "git commit -a") starkers@ubuntu:~/Documents/currentWork/protection_demo$ git add --all starkers@ubuntu:~/Documents/currentWork/protection_demo$ 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:   file (modified content) 

No matter what I do, git commit -am, git commit -a the file will not be added to the commit. Any help?

like image 549
Starkers Avatar asked Sep 25 '14 22:09

Starkers


People also ask

How do I add all modified files to git?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.

How do I add a modified file to github?

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.


2 Answers

I think maybe Jubobs' comment is correct. Is your "file" a submodule?

This line (commit or discard the untracked or modified content in submodules) should not appear for normal files.

Here is what I get from git status:

$ 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)          modified:   README.txt  no changes added to commit (use "git add" and/or "git commit -a") 

You will not see (commit or discard the untracked or modified content in submodules) and (modified content) after my README.txt

So you may need to do what git recommended, work on the content in submodules.

Edit: Previously I thought the "git add ." could solve the issue but now I think it could not.

like image 91
palazzo train Avatar answered Oct 05 '22 03:10

palazzo train


I had this same problem. My personal "aha" was that I had previously added a tracking .git repository file to a subfolder and thus it was seen as a submodule. After removing the .git in the subfolder, it happily joined the rest of my folders as part of just one .git file in the root folder. I didn't even know about submodules so maybe this will help someone as well.

like image 45
Patrick Patterson Avatar answered Oct 05 '22 01:10

Patrick Patterson