【发布时间】:2012-01-18 05:23:18
【问题描述】:
当我执行git commit -a 时,我看到以下内容:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch better_tag_show
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: ../assets/stylesheets/application.css
# modified: ../views/pages/home.html.erb
# modified: ../views/tags/show.html.erb
# modified: ../../db/seeds.rb
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../assets/stylesheets/
# ../views/pages/
那些未跟踪的文件是什么意思?所有的变化都确实被跟踪了。我不明白为什么 git 在这里警告我未跟踪的文件。
编辑:
好的,我看到很多令人困惑的回复。这是我git commit -athis 之后发生的事情。
# On branch master
nothing to commit (working directory clean)
如您所见,除了应用了更改的这四个文件外,没有其他内容。
我的问题应该改写如下:为什么当这个提交中的所有更改都已被跟踪时,git 会警告我未跟踪的文件?
换句话说,git commit 消息中未跟踪的警告是否不必要?
【问题讨论】:
-
(use "git add <file>..." to include in what will be committed) -
zengr 这不是必需的,因为 git commit -a 将提交对已跟踪文件的所有更改。
-
当文件从未被
added 到现在时是必要的。来自-a的文档:告诉命令自动暂存已修改和删除的文件,但您没有告诉 git 的新文件不受影响。 -
你为什么说 git 是在“警告”你?正如我所看到的,“未跟踪”文件消息是信息性的。您可以查看是否需要管理这些文件并采取相应措施。
-
@sateesh 好吧,不管你怎么称呼它,我仍然认为这根本没有帮助。这是如何提供信息的?我应该做些什么?您是否阅读了我在“编辑”部分的帖子,我在其中写道,除了上面列出的文件之外,对任何其他文件都没有修改?如果您发现此信息,则相当于我告诉您,当您无需担心时,不会跟踪您的 repo 树上的任何随机文件夹。
标签: git git-commit