git 添加 .与 git commit -a 比较

发布于 2024-09-15 23:47:59 字数 120 浏览 2 评论 0原文

之间有什么区别:

  • git add .
  • git commit -a

我应该两者都做,还是多余的?

What's the difference between:

  • git add .
  • git commit -a

Should I be doing both, or is that redundant?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梨涡少年 2024-09-22 23:47:59

git commit -a 的意思几乎[*]与 git add -u && 相同。 git 提交

它与 git add . 不同,因为这会添加不会被忽略的未跟踪文件,git add -u 仅对已跟踪的文件进行阶段性更改(包括删除) 。

[*] 如果您不在存储库的根目录中,则会有细微的差别。 git add -u 阶段更新当前目录及以下目录中的文件,它相当于 git add -u .git commit -a 阶段并对所有跟踪文件提交更改。

git commit -a means almost[*] the same thing as git add -u && git commit.

It's not the same as git add . as this would add untracked files that aren't being ignored, git add -u only stages changes (including deletions) to already tracked files.

[*] There's a subtle difference if you're not at the root directory of your repository. git add -u stages updates to files in the current directory and below, it's equivalent to git add -u . whereas git commit -a stages and commits changes to all tracked files.

那小子欠揍 2024-09-22 23:47:59

git commit -a 自动在它知道的所有文件上调用 git add 。您可以使用 git add 来选择要提交的文件。有关更多信息,请参阅文档:此处

git commit -a automatically invokes git add on all files it knows about. You can use git add to select what files to commit. Consult the docs for more info: here

简单爱 2024-09-22 23:47:59

通过使用 git commit -a 开关和 commit 命令自动“添加”所有已知文件(即索引中已列出的所有文件)的更改

By using the git commit -a switch with the commit command to automatically "add" changes from all known files (i.e. all files that are already listed in the index)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文