Why does 'git commit' not save my changes?
Solution 1:
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, you can read an explanation of it here.
For your specific example, you can use:
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).
You can also find general documentation and tutorials for how to use git on the git documentation page which will give more detail about the concept of staging/adding files.
One other thing worth knowing about is interactive staging - this allows you to add parts of a file to the staging area, so if you've made three distinct code changes (for related but different functionality), you can use interactive mode to split the changes and add/commit each part in turn. Having smaller specific commits like this can be helpful.
Solution 2:
You didn't add the changes. Either specifically add them via
git add filename1 filename2
or add all changes (from root path of the project)
git add .
or use the shorthand -a
while commiting:
git commit -a -m "message".
Solution 3:
You should do:
git commit . -m "save arezzo files"
Solution 4:
I copied a small sub project I had that was under Git source control into another project and forgot to delete the .git folder. When I went to commit I got the same message as above and couldn't clear it until I deleted the .git
folder.
It is a bit silly, but it is worth checking you don't have a .git folder under the folder that doesn't commit.
Solution 5:
You could have done a:
git add -u -n
To check which files you modified and are going to be added (dry run: -n option), and then
git add -u
To add just modified files