[英]Difference between git add . and git commit -am “message”
I use Git instructions in this sequence: 我按以下顺序使用Git指令:
However, I learnt from some tutorial that git commit -am "message" does the same. 但是,我从一些教程中了解到git commit -am“ message”的作用相同。 So I began using it in projects and it worked. 所以我开始在项目中使用它,并且它起作用了。
But now when I use commit -am, it doesn't add to staging area and gives this output: 但是现在当我使用commit -am时,它不会添加到暂存区域并提供以下输出:
$ git commit -am "added files in repo"
On branch master
Initial commit
Untracked files:
.RData
.Rhistory
CSV.BAT
ExpenseCalculator.R
GenerateCsv.class
GenerateCsv.java
test.csv
nothing added to commit but untracked files present
So I would like to know the concept behind using the two commands. 因此,我想了解使用这两个命令背后的概念。
git add -a
[or git commit -a
] means any files that have been modified [but not created] in all subdirectories of the working directory, regardless of the current directory will be staged for commit. git add -a
[或git commit -a
]是指已在工作目录的所有子目录被修改[但不能创建任何文件,无论当前目录将上演提交。
On the other hand, git add .
另一方面, git add .
means all files modified [or new files] but descending from the current directory. 表示所有已修改的文件[或新文件],但都属于当前目录。
So, if you have new/changed files that are not in the current directory or one of its subdirectories, these files will not be staged for commit 因此,如果您有不在当前目录或其子目录之一中的新文件/更改过的文件,则这些文件将不会被暂存以进行提交
https://www.kernel.org/pub/software/scm/git/docs/git-commit.html https://www.kernel.org/pub/software/scm/git/docs/git-commit.html
-a is "Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected." -a是“告诉命令自动暂存已修改和删除的文件,但是您未告知Git的新文件不受影响。”
The difference here is that git add also works for unknown (ie new) files. 区别在于git add也适用于未知(即新)文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.