Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git file renaming produces Error: "warning: destination exists; will overwrite!"

Tags:

git

shell

I want to rename my file in my repository locally. So I do:

git mv -f hashpq.py HashPQ.py

And get this:

warning: destination exists; will overwrite!

Then I get the status of git by:

git status

And get thisresponse:

# 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

But after I list my directory by:

ls

I have this:

CHANGLELOG  hashpq.py  NEXTPLAN  README  TODO

I still have hashpq.py unchanged with previous name. How can I rename the file to HashPQ.py?

like image 795
Erfankam Avatar asked Sep 03 '25 04:09

Erfankam


1 Answers

Try renaming it to some temporary name, and then to the name you want:

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

This is the same behaviour as the regular mv command when the file system is case-insensitive.

like image 69
Will Vousden Avatar answered Sep 05 '25 22:09

Will Vousden