Question:
I have modified some of the files in my local git repository but while running git status command before committing, it’s saying “Changes not staged for commit”. Am I doing something wrong?
Answer:
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
1 2 3 4 5 |
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
1 2 |
git commit -a |
Hope it helps.