In Git, git add .
the and git add --all
(or shorthand git add -A
) commands are both used to add files to the staging area, but there are some differences between them.
-
git add .
: This command will add changes to all files and folders in the current directory to the staging area, excluding ignored files (.gitignore
specified by file). It will only add newly created files, modified files and deleted files, and will not operate on unmodified files. It will not handle renamed or moved files. -
git add --all
Orgit add -A
: This command will add changes to all files and folders in the current directory to the staging area, including newly created files, modified files, deleted files, and renamed or moved files. It walks the entire working tree, making sure all changes are added to the staging area.
To sum up, git add .
only focus on newly created, modified and deleted files, but git add --all
also handle renamed or moved files, and ensure that all changes are added to the staging area.
Note that these commands add the changes to the staging area, but do not commit the changes to the repository. To commit changes from the staging area to the repository, use git commit
the command.