我想提交一个Python模块的__init__.py文件,它在我的磁盘上已经包含了代码.但是,对于当前提交,我想将其添加为空,因为这部分代码尚未测试.因此,我用过
$ git add -N __init__.py
Run Code Online (Sandbox Code Playgroud)
该文件存在于输出中git status,但是如果我发出git commit,则所有其他文件都进入提交,除了__init__.py,依次是依次保留在索引中git status.
该名男子页git-add说的-N那个
Record only the fact that the path will be added later. An entry for the path is placed in the index with no content.
Run Code Online (Sandbox Code Playgroud)
有没有办法绕过这will be added later部分,即添加文件为空而不暂时删除其内容?
编辑:当前(2.2.0)Git会发生这种情况.使用1.7.1和一个小的测试仓库,我收到一个错误:
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new …Run Code Online (Sandbox Code Playgroud) git ×1