Reputation: 532
I want to move directory to another directory with history of files under git.
Now i have "defects" folder with classes
I want to move it into "inspections" directory like this:
But after moving i lose all my git history of files in "defects" directory.
Show history gimme an empty result for any file after moving directory
I tried moving with refractor in Android studio and also git mv defects inspections
. Both gave me the same result: "show history" becames empty for any files after moving.
I know that it's not first question by this theme, but i'm really don't know what i'm doing wrong. Please explain me :)
Upvotes: 1
Views: 571
Reputation: 4253
Git does not keep track of files, it keeps track of content. In its brain, files are just metadata. If you ask it for the history a file, it looks up that content in the current snapshot, then tracks the content backward through the history.
If you want to track content across a move, you have to start from its current location and explicitly tell git to look for moved files.
git log --follow -- <file>
should get you where you're going.
Note that git doesn't explicitly track move data, but infers it based on a similarity index. If more than 50% of a file has changed, git will not recognize it as moved by default.
Upvotes: 2