有一个文件filename,由于在更名的同时也做了很大的变动,因此git无法识别这是一个被修改了名字的文件,正确识别应当这样:
➔ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: fileA -> fileB
现在是错误的识别了:
➔ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: fileB
deleted: fileA
那怎么办呢?我是这么做的:
# 先unstage掉fileA,fileB
➔ git reset HEAD fileA fileB
# 用新文件生成老的文件
➔ cp fileB fileA
# 删除新文件
➔ rm fileB
# 使用git mv命令重命名
➔ git mv fileA fileB
# 最后看一下
➔ git status