Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git treat this delete + new as a rename?

Tags:

git

I did some refactoring and git rm on old file and git add on new files. It is showing up as a rename from old file to one of my new files:

renamed:    src/P/Foo/PicturePosition.php -> src/P/Model/Block/Drawing/OffsettedPosition.php

even though I never did any git mv and the files have different content. Why is this happening to me? Should I even try to fix it, and if yes, how?

I use git 1.9.1

like image 878
Jesvin Jose Avatar asked Oct 20 '22 07:10

Jesvin Jose


1 Answers

Git doesn't record renames. It stores just the source trees and infers from the diffs which files were added, deleted, copied, renamed and/or edited.

git mv is just syntactic sugar for a git rm, mv, then git add, and is probably there to make Subversion users feel happier. There is no need to use git mv to inform git that you have renamed a file.

My typical workflow is to just manipulate the files from my shell and editor, then do a git add -Av to tell git to figure out for itself what changes I just made. I don't think I've ever used git mv.

like image 78
pndc Avatar answered Oct 22 '22 23:10

pndc