Question:
I did a git commit -m "message"
like this:
1 2 3 4 5 6 7 8 9 10 11 |
> git commit -m "save arezzo files" # On branch master # Changes not staged for commit: # (use "git add # (use "git checkout -- # # modified: arezzo.txt # modified: arezzo.jsp # no changes added to commit (use "git add" and/or "git commit -a") |
But afterwards, when I do git status
it shows the same modified files:
1 2 3 4 5 6 7 8 9 10 11 |
> git status # On branch master # Changes not staged for commit: # (use "git add # (use "git checkout -- # # modified: arezzo.txt # modified: arezzo.jsp # no changes added to commit (use "git add" and/or "git commit -a") |
What am I doing wrong?
Answer:
As the message says:
no changes added to commit (use “git add” and/or “git commit -a”)
Git has a “staging area” where files need to be added before being committed.
For your specific example, you can use:
1 2 |
git commit -am "save arezzo files" |
(note the extra a
in the flags, can also be written as git commit -a -m "message"
– both do the same thing)
Alternatively, if you want to be more selective about what you add to the commit, you use the git add command to add the appropriate files to the staging area, and git status to preview what is about to be added (remembering to pay attention to the wording used).