作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们在 path/to/another/
中修改了文件和 path/to/main/
.path/to/main/
中的文件已添加到 git 缓存中,但我们已更新 path/to/main/Bar.php
文件 再次 .我们现在有以下情况:
$ git status
[...]
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: path/to/main/Foo.php
modified: path/to/main/Bar.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: path/to/main/Bar.php
modified: path/to/another/Aaa.php
modified: path/to/another/Bbb.php
git add --update
将添加所有这些文件。它不起作用。
modified:
和
new file:
类型。
最佳答案
这显示了仅暂存的文件列表:
git diff --name-only --cached
现在使用它们的新更改暂存这些文件(它将在 bash 中工作)
git add $(git diff --name-only --cached)
PS:(前提条件)运行这些命令时,您需要位于 git repo 的根目录下。在任何子文件夹中运行都不起作用
关于git - 如何在 git 中重新添加添加的文件(仅更新暂存文件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39477305/
我是一名优秀的程序员,十分优秀!