Difference between git add and git commit -a

Viewed 9570

I am trying to better understand how git works.

So we have a working directory (our project files), a staging area (a collection of changes ready to go), and a git repository (where those changes are applied to when committed).

However I am struggling to understand because it seems like files being "tracked" or not refer to some specific thing, and yet we still say each section does its own form of tracking?

Is it correct to say:

  1. If I add or modify a file in my working directory, git detects all of this. Do we say that these files become "tracked" by git at this point? Or are they merely "detected" (or something else)? Is everything in the project folder / working directory "tracked"?

  2. git add {directory or filename} appears to add the contents to the staging area, yes? At this point do we say all staged files are "tracked" files, the ones that show up when we do git ls-files, which I believe shows the files in the staging area? Or no?

  3. git commit -a moves all the changes in the staging area to the repository.

Is this correct?

2 Answers
Related