在不添加到索引的情况下开始在Git中跟踪文件 [英] Start tracking a file in Git without adding to to the index

查看:86
本文介绍了在不添加到索引的情况下开始在Git中跟踪文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在git中开始跟踪文件而无需将其添加到索引中?

Is it possible to start tracking files in git without adding them to the index?

我有一些新文件,它们希望在git clean中保存,但是在下一次提交之前可能会更改.我现在是否只是将它们添加到索引中,然后稍后在提交之前再次添加它们?

I have new files which I'd like to survive a git clean, but will likely change before the next commit. Do I simply add them to the index now, and then add them again later just before the commit?

推荐答案

似乎在寻找git add --intent-to-add(或git add -N).来自官方git add文档:

Seems like you're looking for git add --intent-to-add (or git add -N). From the official git add documentation:

-N
--intent-to-add

仅记录以下事实:以后将添加路径.路径的条目放置在索引中,不包含任何内容.除其他功能外,这对于使用git diff显示此类文件的未暂存内容并使用git commit -a提交它们很有用.

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.

请参见

See the What does git add --intent-to-add or -N do and when should it be used? question for more information.

这篇关于在不添加到索引的情况下开始在Git中跟踪文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆