我想在本地重命名存储库中的文件。所以我这样做:
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/