'git add .' 是什么?('git add'单点)命令做什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16969768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:21:01  来源:igfitidea点击:

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

gitgit-add

提问by chunjw

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 命令的含义:

$ git add .

What does this do?

这有什么作用?

回答by agconti

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

git add .添加/暂存当前目录中的所有文件。这是为了方便起见,如果您不想使用某些文件添加某些文件,仍然可以使用.gitignore

A tutorial for .gitignoreis located here.

的教程.gitignore位于此处

A deeper look into git add .vs git add -Avs. git add -uis located hereand 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 .vs git add -Avs.git add -u位于此处,如果您想更多地控制如何添加所有文件/想知道如何git add .工作,它可能会回答您的问题。

回答by Klas Mellbourn

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.

git add .将当前目录和所有子目录中的所有修改过的和新的(未跟踪的)文件添加到暂存区(又名索引),从而准备将它们包含在下一个git commit.

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

任何与文件中的模式匹配的.gitignore文件都将被忽略git add

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

如果您想跳过该git add .步骤,您可以将-a标志添加到git commit(尽管这将包括所有修改过的文件,而不仅仅是在当前目录和子目录中)。

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

请注意,git add .不会对已删除的文件做任何事情。要在索引中包含删除(以及即将提交的提交),您需要执行以下操作git add -A

回答by Lenin

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

它将该文件夹下的所有后续资源(您对其进行了更改)添加到 Git 的版本控制以进行提交。

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

你应该从这个优秀的演练中学习 Git学习 Git 的资源