There are subtle differences between git and other cloud-based /
svn repository systems. One of which is the fact git has
a so-called "staging area
".
git add
In git before a file is updated in your repository, at first it's added to a so called staging area
.
This is done exactly, as the name of the function would suggest, via the git add
command.
During the staging stage, you tell your git which files you want to update.
This also means, you can remove certain updates in staging area, if you change your mind about them.
git commit
Once you produce a version, that you think is ready to be posted into a repository, you can commit the changes so you and others can see them.
Once again, command named derivated from the action described, so in this case it would be git commit
which commits the changes you have proposed in your staging area (via git add
).
So the difference is, if you use internet browser to upload files directly into a repository, you essentially skip the git add
stage and you do git commit
the files do the repository straight away.
Now, if you have a git
project you manage only yourself, then yeah, git add
is essentially useless for you. However, on a large project where you've got multiple people working, you want to make sure you don't over-write people's code, or just want to make sure you do properly version-manage, it is essential to properly utilize the staging area.
One of main advantages are, that during the commit phase, you don't usually commit a single file, however multiple changes, which makes it easier to keep track of who did what, rather than looking up every single file one by one.
For more info (not only on) git add
and git commit
I would thoroughly recommend studying this guide. At least personally speaking, I became fluent in git from this resource alone