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?
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .
In Git 2. If you are in any subdirectory of the working directory, git add -A will add all files from the entire working directory, and git add . will add files from your current directory.
This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index.
The git add command adds new or changed files in your working directory to the Git staging area. git add is an important command - without it, no git commit would ever do anything.
Being able to shape your history is one of the greatest advantages of using Git. If your commits are too large, contain unrelated changes, or are unclearly described in the commit message, you will lose the benefits of viewing and changing history. By using an option to add all files at once, you may accidentally stage and commit a file.
git add . stages all modified or untracked files in current directory and all subdirectories. git add *.c adds all files with .c extension. * is called "a star wildcard" and it matches any characters. Eg. if you wanted to add any files with extension starting with .c, you could achieve it with git add *.c*.
git add [filename] selects that file, and moves it to the staging area, marking it for inclusion in the next commit. You can select all files, a directory, specific files, or even specific parts of a file for staging and commit. This means if you git add a deleted file the deletion is staged for commit.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With