What does the 'git add .' ('git add' single dot) command do?

77,901

Solution 1

git add . adds / stages all of the files in the current directory. This is for convenience, and can still be used if you have certain files you don't want to add by using a .gitignore

A tutorial for .gitignore is located here.

A deeper look into git add . vs git add -A vs. git add -u is located here and it might answer your question if you wanted more control of how you add all of the files / wanted to know how git add . works.

Solution 2

git add . adds all modified and new (untracked) files in the current directory and all subdirectories to the staging area (a.k.a. the index), thus preparing them to be included in the next git commit.

Any files matching the patterns in the .gitignore file will be ignored by git add.

If you want to skip the git add . step you can just add the -a flag to git commit (though that will include all modified files, not just in the current and subdirectories).

Note that git add . will not do anything about deleted files. To include deletions in the index (and the comming commit) you need to do git add -A

Solution 3

It adds all subsequent resources (on which you have made changes) under that folder to Git's version control for commit.

You should learn Git from this excellent walkthrough: Resources to learn Git

Share:
77,901
chunjw
Author by

chunjw

I use Javascript, Coffeescript, HTML5, Node.js, Python, Matlab among others. I'm interested in web technologies as well as data analytics.

Updated on July 05, 2022

Comments

  • chunjw
    chunjw almost 2 years

    I don't get what the Git command means, when adding files to the stage with the use of a period (or full stop, single dot):

    $ git add .
    

    What does this do?

  • Adrián Jaramillo
    Adrián Jaramillo over 3 years
    does git add . goes recursively or not? @agconti
  • Robin Clower
    Robin Clower over 2 years
    Yes, git add . will add all files contained in the parent and children directories.