Git 文件重命名产生错误 : "warning: destination exists; will overwrite!"

标签 git shell

我想在本地重命名存储库中的文件。所以我这样做:

git mv -f hashpq.py HashPQ.py

得到这个:

warning: destination exists; will overwrite!

然后我通过以下方式获取 git 的状态:

git status

并得到这个响应:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    hashpq.py
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   hashpq.py

但是在我通过以下方式列出我的目录之后:

ls

我有这个:

CHANGLELOG  hashpq.py  NEXTPLAN  README  TODO

我的 hashpq.py 仍然保持原名不变。 如何将文件重命名为 HashPQ.py?

最佳答案

尝试将其重命名为某个临时名称,然后再重命名为您想要的名称:

git mv hashpq.py _hashpq.py
git mv _hashpq.py HashPQ.py
git commit

当文件系统不区分大小写时,这与常规 mv 命令的行为相同。

关于Git 文件重命名产生错误 : "warning: destination exists; will overwrite!",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10595425/

相关文章:

git - 在 Laravel 5 应用程序中,环境特定的值应该保存在哪里?

php - Rancher 操作系统 : generate data in one container and set as environment variable in another container

shell - KSH 检查字符串是否以子字符串开头

git - 如何在 git-svn 中设置上游分支?

当我切换分支时,Git 正在删除一个被忽略的文件

git - Gerrit :! [远程拒绝] HEAD -> refs/publish/master(无新变化)

mysql - shell脚本中使用的mysql语句语法错误

perl - 如何使用shell脚本来监督一个程序?

android - 如何将 adb screenrecord 输出重定向到 pc(windows/linux) 存储

git - 将现有项目推送到远程服务器