Does git add do recursively?

Posted in Articles

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Let’s say you do the git command …

git add .

or

git add -A .

See what is the difference between the two commands.  The . means is the <pathspec> for the current directory.  We understand that it adds all files of the current directory to the index to be staged for commit.  But what if you have a subdirectory?  Will it add those files too.

The answer is yes.  It add recursively all files and directories if the <pathspec> is a directory such as “.”.   If the <pathspec> is a set of files, then it does not.

From the git documentation, it writes …

“The git add command takes a path name for either a file or a directory; if it’s a directory, the command adds all the files in that directory recursively.”