The command git add [--all|-A]
appears to be identical to git add .
. Is this correct? If not, how do they differ?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Things changed with Git 2.0:
-A
is now the default--ignore-removal
git add -u
andgit add -A
in a subdirectory without paths on the command line operate on the entire treeSo for git 2 the answer is:
git add .
andgit add -A .
add new/modified/deleted files in the current directorygit add --ignore-removal .
adds new/modified files in the current directorygit add -u .
adds modified/deleted files in the current directoryIn Git 2.x:
If you are located directly at the working directory, then
git add -A
andgit add .
work without difference.If you are in any subdirectory of the working directory,
git add -A
will add all files from the entire working directory, andgit add .
will add files from your current directory.And that's all.
With Git 2.0,
git add -A
is default:git add .
equalsgit add -A .
.git add
is likegit add :/
(add everything from top git repo folder).Note that git 2.7 (Nov. 2015) will allow you to add a folder named "
:
"!See commit 29abb33 (25 Oct 2015) by Junio C Hamano (
gitster
).Note that starting git 2.0 (Q1 or Q2 2014), when talking about
git add .
(current path within the working tree), you must use '.
' in the othergit add
commands as well.That means:
(Note the extra '
.
' forgit add -A
andgit add -u
)Because
git add -A
orgit add -u
would operate (starting git 2.0 only) on the entire working tree, and not just on the current path.So from Charles instructions above, after testing my proposed understanding would be as follow:
This link might also be helpfull to understand in what situation those commands may be applied: Removing Deleted Files from your Git Working Directory.
The -A option adds, modifies, and removes index entries to match the working tree.
In GIT 2 the
-A
option is now default.When a
.
is added that limits the scope of the update to the directory you are currently in, as per the Git documentationOne thing that I would add is that if the
--interactive
or-p
mode is used then git add will behave as if the update (-u
) flag was used and not add new filesHere is table for quick understanding:
Git Version 1.x:
Git Version 2.x:
Long-form flags:
git add -A
is equivalent togit add --all
git add -u
is equivalent togit add --update
Further reading: