git add Command
git add The command can add the changes to the file to the staging area.
By running the git add command, you can tell Git which file changes should be included in the next commit.
Add one or more files to the staging area:
git add [file1] [file2] ...
Add a specified directory to the staging area, including subdirectories:
git add [dir]
Add all files in the current directory to the staging area:
git add .
In the following example, we add two files:
$ touch README # 创建文件
$ touch hello.php # 创建文件
$ ls
README hello.php
$ git status -s
?? README
?? hello.php
$

The git status command is used to view the current status of the project.
Next, we execute the git add command to add the files:
$ git add README hello.php
Now, if we run git status again, we can see that the two files have been added.
$ git status -s
A README
A hello.php
$

In a new project, it is common to add all files; we can use the git add . command to add all files of the current project.
Now, let's modify the README file:
$ vim README
Add the following content to the README:# Runoob Git Test, then save and exit.
Run git status again:
$ git status -s
AM README
A hello.php

The AM status means that the file was modified again after we added it to the cache. After the modification, we run the git add . command again to add it to the cache:
$ git add .
$ git status -s
A README
A hello.php
After a file is modified, we generally need to perform a git add operation to save the historical version.
Git Basic Operations