The git add
command is one of the most popular commands for the Git systems. The “git add” command is used to add file changes to the next commit. This can be also called adding changes to the Git Staging Area where the next commit uses the staging area.
git add Help Information
The “git add” command provides different options. These options and related information can be displayed with the -h
option.
$ git add -h

git add Single File
The git add command is used to add a single file to the staging area. The filename is specified as a parameter to the “git add” command.
$ git add host.c
Alternatively, we can specify the file absolute or full path to add a stanging area.
$ git add /home/ismail/nmap/host.c
git add Multiple Files
The “git add” command can be also used to add multiple files in a single execution. The filenames are provided as parameters to the “git add” command.
$ git add host.c server.c client.c
Alternatively, files can be specified with their absolute or full paths.
$ git add /home/ismail/nmap/host.c server.c client.c
git add File Extension
The git add can be used to add files according to their extensions. In the following example, we add all *.c
files to the staging area with the “git add” command.
$ git add *.c
git add All Files
There may be modified files located in different paths and directories in a project. Adding them to the staging area one by one or using different directories are not always practical. We can use the -p
option in order to add all files in different locations.
$ git add --all