What Does "git add ." Do?

The git add command in general is used to add changed files in the current working directory to the staging area to tell git which files are going to be a part of the next commit.

The dot in the git add . command is simply a pathspec (which may also be a filepath), that tells git to only look for changed files in the current directory (i.e. it omits paths found in directories above and below). There is, however, one important thing to know about the git add . command:

  • In Git v2.x, it stages new, modified, as well as deleted files in the current folder;
  • In Git v1.x, it only stages new and modified files in the current folder.

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.