Reputation: 51100
When I look at the history of FileA.cs and FileB.cs, they both reference the history of FileA.cs
At some point these files were just a single file: FileA.cs and some functionality got split out into two files. The person committing probably didn't commit properly and now it seems the history for these two files are bonded together. Git seems to think they are the same file or something.
Can I tell git to treat them as separate files somehow?
Edit: I can't see the history of FileB at all. I can only see the history of FileA which doesn't show any of the content that is now no longer in FileA (because it's in FileB). I want to use Blame on FileB but I can't because it's using FileA's history and won't show the lines that are in FileB.
Numbers.cs (original file / FileA)
11111111
22222222
33333333
44444444
55555555
66666666
Numbers.cs (after split / FileA)
11111111
33333333
55555555
EvenNumbers.cs (after split / FileB)
22222222
44444444
66666666
In this example, I no longer have any access to history to the 2,4,6 lines of code even though they still exist in a new file. That file uses the Numbers.cs history for some reason.
Upvotes: 1
Views: 174
Reputation: 213268
Git doesn't work that way. Whoever made the commit didn't do anything wrong with the Git command.
Git does not record the history of a file, instead, it reconstructs the history of a file from the history of the entire repository. If Git claims that two files are the same file, that is because at some point, the content of the two files was practically identical.
Here's a clearer example of how Git works: If you move file A to file B, Git will show that in the history logs. However, all it actually records is that file A is deleted and file B is created — but since they have the same content (or close enough), Git describes it as a "move" — recognizing the move happens when you ask for the logs, and it's not "recorded" as a move in the actual repo.
The summary: Git is just guessing that the file was moved or copied, it's not actually recorded that way in the repository. Sometimes Git guesses wrong. You can change the rules for its guesses. The history is still there, you just have to ask for it differently.
Upvotes: 3
Reputation: 421
Git tracks content not files. So No, you can not split the history.
Upvotes: 3