【发布时间】:2014-11-21 16:52:30
【问题描述】:
我刚刚做了git rm file1.c 之后git status 显示
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: file1.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
dir/file2.c
dir/file3.c
到目前为止一切顺利。但是如果我git add dir/file2.c 我得到了
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: file1.c -> dir/file2.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
dir/file3.c
这是一个错误还是我做错了?我希望新文件被列为新文件。除了简短的版权声明 [\edit] 之外,file1.c 和 file2.c 没有任何相似的内容 [edit]。
【问题讨论】:
-
文件短吗?如果是这样,Git 可能会错误地检测到重命名。不过不用担心……历史上没有记载的。 Git 会在每次需要重命名时尝试检测它们。如果你想避免它,删除文件,提交,添加文件,进行第二次提交。
-
是的,它们很短。也许再加上他们实际上有一个小的版权声明这一事实让 git 认为这是一个重命名。
标签: git