Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changes not staged for commit even after git add

Here are the git commands which I have typed

$ git add -u -n
add 'proj1/Foo.scala'
$ git add .
$ git add .
$ git commit -m "message"
On branch feature/branch
Your branch is up-to-date with 'origin/feature/branch'.
Changes not staged for commit:
    modified:   ../proj1/Foo.scala

So why did I get the Changes not staged for commit? as you can see that I did git add . twice

Now if I got ahead and do

git add ../proj1/Foo.scala

and then do commit it works. Why should I do each file specifically rather than just do git add .

like image 850
Knows Not Much Avatar asked Mar 29 '16 17:03

Knows Not Much


2 Answers

git add . by default will add files changed in current working directory and its subdirectories only.

If you want to add all files, use git add -A (this works in the latest versions of git).

Alternatively, as pointed by @Zak in comments, you can use git commit -am "commit message" to do this in a single step.

like image 133
Anshul Goyal Avatar answered Sep 22 '22 14:09

Anshul Goyal


I had a similar problem when git add <filename> did not work.
I cd down to the directory and did git add there and file was added as expected.

like image 26
LosManos Avatar answered Sep 22 '22 14:09

LosManos