Git BUG – changing file name.

Bug Description

While you re-name file in your repository from (for example) ClassName to Classname, git will not mark it as a change. Bug is reproducable only when you (de)capitalize a letter in file name.


This can cause problems, because although your local copy will be ok, when you commit such change, other developers (Jenkins) will have inconsistent code. This could lead to compilation errors (when you rename .java class), or other issues.


!!IMPORTANT!!
This issue can be easily reproduced, while you refactor your code in IDE (Intellij, Eclipse etc…). So be aware that something like this can happened.


During my work with GIT (Since February 2012 all commercial project I was involved in and all my personal ones are run using git), I have came across this error few times. It is quite irritating and is coming unexpected. I was lucky enough to have my project fast-fail (on fiend’s repository) on compilation level when this problem occurred. But anyway, I was to blame for committing not compiling code.


Work around

Before you commit any code you can run:
git reset .
and after that you can safely:
git add . (git add -u )
After that git will stage it from the beginning and above bug will not occur.
 
I have tested this on mac and windows , on both it is reproducable:

  • git version 1.7.12.4 (Apple Git-37)
  • git version 1.8.0.msysgit.0


How to reproduce

There is a simple path how you can reproduce this bug. Versions:

  1. git init
  2. touch .gitignore
  3. git add .gitigore
  4. git status -s
  5. git commit -m „Initial commit”
  6. touch MainClass.java
  7. git add .
  8. git status -s
  9. ls
  10. mv MainClass.java Mainclass.java
  11. ls
  12. git status -s
  13. git diff master
  14. git reset .
  15. git add .
  16. ls
  17. git status -s
  18. git diff master


Screenshot of whole path.

Screen Shot 2013-05-27 at 13.19.22


Reklamy

Jedna uwaga do wpisu “Git BUG – changing file name.

  1. you need to use

    git config core.ignorecase false

    and then git mv

    this is only an issue in OSX and Windows where filenames are handled in a case insensitive manner, not an issue in Linux and other Unix systems

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s