当我执行 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 -a”之后发生的事情。
# On branch master
nothing to commit (working directory clean)
正如您所看到的,除了那四个文件被更改之外,没有其他任何内容。
我的问题应该重新表述为:当此提交中的所有更改都已被跟踪时,为什么Git会警告我有未跟踪的文件?
换句话说,Git提交信息中的未跟踪警告是否是不必要的?
(use "git add <file>..." to include in what will be committed)
- zengradd
过,那么使用-a
是必要的。从-a
的文档中可以看到:告诉命令自动暂存已修改和删除的文件,但是新添加的文件不受影响,因为你还没有告诉 Git 这些文件的存在。 - Noufal Ibrahim.gitignore
吗?你很可能需要这样的文件! - Basile Starynkevitch