Should I have to add files to git every time I want to commit?
This allows you to separate commits by edits. If you only want to commit these files now, under one commit, and then these next files now, under a second commit, you could do:
git add files_under_one_topic
git commit -m "this is about one thing"
git add files_left_over_to_commit_about_a_completely_different_topic
git commit -m "this is about another thing."
Git works by using a "staging" area where you prepare what you are going to bundle together as a commit. So, you decided what set of changes you want to commit (e.g. all or a subset), you add them to the staging area, and then you commit what's in the staging area.
When you invoke git status
, it shows you what has been added to the staging area (i.e. "Changes to be committed"), what has been modified among the files git is tracking (i.e. Changed but not updated"), and any new files that you've never added before (i.e. Untracked files).
If you want to just commit stuff that you've changed, but not include newly created files you can use git commit -a -m "Comment for modified files already under source control."