git - 将未跟踪文件添加到 GIT 中的未暂存区域

标签 git

默认情况下,如果我使用 git add ,它会直接将文件添加到暂存区。 我想要它,仅将其添加到未暂存区域。怎么做?

最佳答案

您可能正在寻找 --intent-to-add 选项:

-N, --intent-to-add

Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, showing the unstaged content of such files with git diff and committing them with git commit -a.

这会将文件作为空文件添加到索引中,这将使 git diff 将其所有内容显示为“已添加”。

关于git - 将未跟踪文件添加到 GIT 中的未暂存区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46736046/

相关文章:

git - 如何从给定的提交哈希中获取时间戳中立的 git 哈希

git - merge svn 分支到新的 git 分支

git - 如何通过非交互式压缩除最近的提交之外的所有提交来减小臃肿的 Git 存储库的大小?

GitHub:如何将 Gist 添加到存储库?

bash - 如何在 git safe.directory 上递归添加目录?

git - 如何诊断和修复 git fatal : unable to read tree

Git:如何通过访问控制保护 git-flow 中的 develop/master 分支(来自菜鸟)?

git - 另一个 git 进程似乎正在运行,因此无法提交

git - 在 git 中移动分支路径(更改其名称,而不是其代码)

git - Jenkins 实例丢失