git add .
, git add -A
stage all files, including new files (which git commit -a
misses) and deleted files.
The difference is that git add -A
also stages files in higher directories that still belong to the same git repository. Here's an example:
/my-repo
.git/
subfolder/
nestedfile.txt
rootfile.txt
If your current working directory is /my-repo
, and that's the root of this git repo (thus the .git/
folder), these two commands will do the same thing.
But if you rm rootfile.txt
, then cd subfolder
, git add .
will not stage the change that ../rootfile.txt
has been deleted, because git add .
only affects the current directory and subdirectories. git add -A
, on the other hand, will stage this commit.
git add -A
- сохраняет изменения всех файлов иерархии
git add .
- сохраняет изменения всех файлов текущей директории и всех подкаталогов, но не файлов подкаталогов.
В примере мы удалили файл в директории, поднялись на уровень выше. Удаление файла не будет фиксироваться с помощью git add .
git commit -a
- можно сразу делать коммиты без git add
, но не будут добавляться созданные(новые) файлы в коммит.
git add -u
- не сохраняет новые файлы
git add --ignore-removal
- не сохраняет удаленные файлы
git add -A
- самый универсальный способ для добавления всех файлов для коммита.