“命令”;git添加<;文件>&引用;将所有文件添加到阶段

“命令”;git添加<;文件>&引用;将所有文件添加到阶段,git,Git,有很多git命令可以指定文件名。它们在我的项目中似乎不起作用,因为这些命令仍然适用于所有文件,而不是一个文件 示例: git add <file> # causes adding all files to the stage, not just one git checkout <file> # discard all changes git log -- file # works as usual git log command git blame <file&g

有很多git命令可以指定文件名。它们在我的项目中似乎不起作用,因为这些命令仍然适用于所有文件,而不是一个文件

示例:

git add <file> # causes adding all files to the stage, not just one
git checkout <file> # discard all changes
git log -- file # works as usual git log command
git blame <file> # this one seems to work right

您正在使用的文字命令是什么
git add path/to/file
应仅(且仅)将此文件添加到暂存区域,不会添加其他文件。如何检查将哪些更改添加到临时区域
git status
仅将此单个文件显示为“待提交”您还可以使用
git reset
从临时区域删除无意添加的文件…@knittl我用git add的详细示例更新了我的问题“所有更改”是什么?如果更改包含文件中的所有行,则提示行尾有问题。如果单个文件包含混合的Windows和Unix行结尾,这可能会导致问题,具体取决于配置。提交文件时,行尾是标准化的。Git与Windows行尾一起工作。但根据配置,您可能会遇到奇怪的行为。看看这是否对你有帮助。另外,请检查行结尾的当前配置(
git config
.gittributes
$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   file1
        modified:   file2
        modified:   file3

$ git add file1
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   file1
        modified:   file2
        modified:   file3