git - 在不添加到索引的情况下开始在 Git 中跟踪文件

标签 git

是否可以在不将文件添加到索引的情况下在 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 with git 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/

相关文章:

git - VSTS - 从一个存储库持续部署到两个独立的 Azure Web 应用程序

git - 为什么 GitHub 只需要我的公钥就可以推送?

git - 设置 Git 远程 SSH (git-upload-pack/git-receive-pack)

git clone 和 pull 省略大文件

linux - 如何在我分发的包中使用 git

java - 如何在 Eclipse 中使用 EGit 导入 gradle 项目? (libGDX)

git - 撤销提交时删除提交历史

git - 如何判断当前工作目录是否被 Git 忽略?

git - 灵活与静态分支(Git与Clearcase/Accurev)

git - 恢复通过 git -f --mirror 在远程 Github 存储库上删除的分支