newBike newBike - 1 year ago 296
Git Question

What does "Changes not staged for commit" mean

I thought if you want to track the files you should

git add [files you want to track]

I don't know why I got the messages
Changes not staged for commit

If those files were not staged, shouldn't
shows me those files were
like that

enter image description here

All I've done was create a new feature from
branch and worked in

I thought Those files should be in

git status
told me
Changes not staged for commit

enter image description here

To brief,
I only know there are 3 stages in git

Can any one tell me , what was the stage in for
Changes not staged for commit

enter image description here

So if I modified the file
(already in the repo)

and type
git st
, the git will tell me
Changes not staged for commit

if I
git a
then the file
will be in
staged status

if I modified the
file a
now, there will be two status of
file a
, right ?

So I have to decide if make the
staged a
be commit or make the
not stage a
to be staged,
and then the previous staged
file a
will be discard ?

enter image description here

Answer Source

when you change a file which is already in the repository, you have to git add it again if you want it to be staged.

This allows you to commit only a subset of the changes you made since the last commit. For example, let's say you have file a, file b and file c. You modify file a and file b but the changes are very different in nature and you don't want all of them to be in one single commit. You issue

git add a
git commit a -m "bugfix, in a"
git add b
git commit b -m "new feature, in b"

As a side note, if you want to commit everything you can just type

git commit -a

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download