Mohamed Taboubi
Mohamed Taboubi

Reputation: 7011

Change name file not updated in GIT

I have a file called member.java" I committed and pushed this file using GIT. After that I changed the name to Member.java (M Uppercase) -- however every time I want to commit the file GIT write it member.java (m in lowercase) ...

enter image description here

How can I resolve this problem ? thanks

Upvotes: 3

Views: 2109

Answers (2)

Shravan40
Shravan40

Reputation: 9888

You can do this in two ways

  • git mv -f member.java Member.java

Or, If ignore case option is available in your git version

  • If you would like to do this for one project, run this from project directory git config core.ignorecase true
  • If you would like to do this for all project then git config --global core.ignorecase true

Upvotes: 4

VonC
VonC

Reputation: 1323273

You need to make sure you are using git 2.0 or more in your IDE. (see "Changing capitalization of filenames in Git").
IntelliJ, for instance, checks the OS vs. its case sensitive policy.
To be sure, fall back to command line (with git for Windows 2.9.2) and do a

git mv member.java Member.java

(no need for git mv --force anymore)

Add, commit then switch back to your IDE: check after a refresh it does reflect the case change.


IntelliJ has an interresting blog post last month: "How to Support Case-only Rename in Git"

Things got really interesting when we tried to commit these rename changes, which were already properly recognized by Git.
In Git CLI, as well as in most of the clients, you just call git commit and commit everything that is staged.
However, in IntelliJ IDEA we call git commit --only -- <paths> which lets commit only selected files, regardless of whether they are staged or not. This allows you, the user, to select paths from the UI and not think about Git indexes.

The problem here is that Git doesn’t allow the --only syntax for case-only renames, so git commit --only MyClass.java Myclass.java simply fails

You would need the recent IntelliJ IDEA 2016.2 EAP (June 2016) to benefit from their workaround allowing you to rename files in a case-insensitive (but case-preserving) OS environment.

It finally solves issue IDEA-53175 (March 2010).

Upvotes: 2

Related Questions