GitHub diff not working and line numbers messed up.

Not sure what caused this problem or if anyone else has had it, but I figured out a solution so I thought I’d share.


When making changes to files that are version controlled through git hub, the “diff” function behaves erratically, showing something like this (I’m using SourceTree here):

A few weird things going on here:

  • Line numbers are all screwed up and seem to only be single digits for both the right and left columns.
  • The first line is shown as deleted (in red), then the entire document contents are shown, followed by the new document contents with the first line shown as added (in green).
  • If you look close, you can see that the actual change was I deleted one of the blank lines after “public var height:Number;”
  • In the third column to the right of the line numbers, you can see the first character of each line (ie: the “p” from the “public class …” line). Very strange.

No idea how this happened. I am using FlashBuilder as an editor for these documents, and perhaps that caused some sort of weirdness. In any case, on to the (relatively) simple fix.


Simply select the entire contents of the document, Ctrl-X to cut, save the blank document, then paste the contents back in and save again. With a lot of files this is probably a pain in the ass, but at least it fixes the issue. Let me know if you have any better fixes or know what causes it. Here’s how the above should have looked:

Side note: It doesn’t seem to be a problem with the Git client (I’m using SourceTree) as I tested it the issue with GitHub for Mac and GitX clients and both displayed similar weirdness.