Git commit -a"未跟踪文件"?

dis*_*dng 79 git

当我这样做时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/
Run Code Online (Sandbox Code Playgroud)

那些未跟踪的文件是什么意思?确实跟踪了所有的变化.我不明白为什么git会在这里警告我未跟踪的文件.

编辑:

好的,我看到很多混淆的回复.这就是我git commit -a这之后发生的事情.

# On branch master
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,除了那些已应用更改的四个文件之外,没有其他内容.

我的问题应该改写如下:为什么当跟踪此提交中的所有更改时,git会警告我未跟踪的文件?

换句话说,git commit消息中未跟踪的警告是否不必要

cod*_*iot 88

对于有相同问题的其他人,请尝试运行

git add . 这将添加当前目录的所有文件进行跟踪(包括未跟踪),然后使用

git commit -a 提交所有跟踪的文件.

正如@Pacerier所建议的那样,一个做同样事情的班轮是

git add -A

  • git commit -a将提交所有跟踪的文件,而不跟踪未跟踪的文件。git add。将跟踪当前目录中未跟踪的文件。git add -a将跟踪所有未跟踪的文件。 (3认同)

zen*_*ngr 28

git commit -am "msg"git add file和和不一样git commit -m "msg"

如果您有一些从未添加到git跟踪的文件,您仍然需要这样做 git add file

"git commit -a"命令是两步过程的快捷方式.在修改了repo已知的文件后,你仍然要告诉回购,"嘿!我想将它添加到暂存文件并最终提交给你."这是通过发出"git add"命令完成的."git commit -a"正在暂存文件并一步提交.

来源:"git commit -a"和"git add"


Tra*_*lly 8

您应该键入命令行

git add --all
Run Code Online (Sandbox Code Playgroud)

这将提交所有未跟踪的文件

  • 这_stages_所有文件,而不是_commit_它们。您仍然必须单独进行操作。 (2认同)

小智 8

  1. 首先,您需要添加所有未跟踪的文件。使用以下命令行:

    git add *

  2. 然后使用以下命令行提交:

    git commit -a


sat*_*esh 7

顾名思义,“未跟踪的文件”是 git 未跟踪的文件。它们不在您的暂存区域中,也不属于任何先前提交的一部分。如果您希望对它们进行版本控制(或由 git 管理),您可以通过使用“git add”告诉“git”来实现。查看Progit书中的Recording Changes to the Repository这一章,它使用漂亮的视觉效果提供了有关记录 git repo 更改的良好解释,并解释了术语“已跟踪”和“未跟踪”。


Ali*_*kan 5

如果您遇到未跟踪文件的问题,此3行脚本将为您提供帮助。

git rm -r --cached .
git add -A
git commit -am 'fix'
Run Code Online (Sandbox Code Playgroud)

然后就 git push