【发布时间】:2014-12-07 04:03:13
【问题描述】:
我有两个文件已经在 git 中添加并提交。
报告
报告日期
现在,我修改了这两个文件并尝试提交,但在我将它们添加到暂存区域后,git 错误地将 report_dates 文件标记为重命名。
> git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: report
modified: report_dates
> git add report
> git add report_dates
> git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: report_dates -> report
modified: report_dates
我尝试使用 git commit --dry-run 进行验证,这也显示文件已重命名。提交会覆盖原始文件吗?有两个不同的文件,90% 的内容相似。
【问题讨论】:
-
这就是 git 的工作方式。如果文件内容更改太多,有时它不会检测到实际的重命名。你应该接受它并继续前进:)
-
stackoverflow.com/q/26273245/6309 中的相同: git status after 提交将起作用。
-
感谢@VonC
git commit --dry-run将其显示为重命名。我还能继续承诺吗? @AlexMDC 这不是重命名,但 git 将其报告为重命名。 -
当然:如果不成功,您仍然可以重置为上一次提交。
-
提交后正确显示
标签: git