Since git 2.0, git add -A
and git add -A :/
are the same.
But the magic pathspec :/
is not new and dates back from git 1.7.6 (Apr 2011). See commit 8a42c98. It is documented in Documentation/glossary-content.txt
A pathspec that begins with a colon :
has special meaning.
In the short form, the leading colon :
is followed by zero or more "magic
signature" letters (which optionally is terminated by another colon :
),
and the remainder is the pattern to match against the path.
:top: or :/
The magic word top
(magic signature: /
) makes the pattern match from the root of the working tree, even when you are running the command from inside a sub-directory.
Note that if you want to add a folder named ':/
' (git add -A :/
), this will be possible only in git 2.7 (Nov 2015)
See commit 29abb33 (25 Oct 2015) by Junio C Hamano (gitster
).
Since Git 2.0, "add -u
" and "add -A
" run from a subdirectory without any pathspec mean "everything in the working tree" (before 2.0, they were limited to the current directory).
The limiting to the current directory was implemented by inserting ".
" to the command line when the end user did not give us any pathspec.
At 2.0, we updated the code to insert ":/
" (instead of '.
') to consider everything from the top-level, by using a pathspec magic "top
".
(This is no longer needed, and fixed in said commit 29abb33: the implementation of git add -A
no longer use :/
for the upcoming git 2.7)
Incidentally such a simplification also fixes a corner case bug that
stems from the fact that ":/
" does not necessarily mean any magic.
A user would say "git --literal-pathspecs add -u :/
" from the command line when she has a directory ':
' and wants to add everything in it (and she knows that her :/
will be taken as 'everything under the sun' magic pathspec unless she disables the magic with --literal-pathspecs
).
The internal use of ':/
' would behave the same way as such an explicitly given ":/" when run with "--literal-pathspecs", and will not add everything under the sun as the code originally intended.
Since that internal use of :/
is no more, a git --literal-pathspecs add -u :/
will actually work, and add files under the folder named "column" (':
').
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…