是否可以在不将文件添加到索引的情况下在 git 中开始跟踪文件?
我有一些新文件,我想在 git clean
中保留下来,但可能会在下一次提交之前更改。我现在只是将它们添加到索引中,然后在提交之前再次添加它们吗?
最佳答案
您似乎在寻找 git add --intent-to-add
(或 git add -N
)。来自 the official git add
documentation :
-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 withgit commit -a
.
参见 What does git add --intent-to-add or -N do and when should it be used?问题以获取更多信息。
关于git - 在不添加到索引的情况下开始在 Git 中跟踪文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10213117/