3

Recently we add SVG files to our Git repository frequently. The problem is SVG file diff is really annoying to see other diff on GitHub.

The diff is like this

+   <path class="st3" d="M179.7,29l-0.6-4c-0.1-0.7,0-1.3,0.4-2c1.5-2.8,2.6-6.2,3.4-10.3c0-0.3,0.2-0.5,0.4-0.6s0.5-0.2,0.8-0.1
+       l2.1,0.6c0.3,0.1,0.5,0.2,0.7,0.5s0.2,0.5,0.2,0.8c-0.3,2.2-0.8,4.2-1.4,6c0,0.1-0.1,0.2-0.1,0.3v18c0,0.3-0.1,0.6-0.3,0.8
+       c-0.2,0.2-0.5,0.3-0.8,0.3h-2.1c-0.3,0-0.6-0.1-0.8-0.3c-0.2-0.2-0.3-0.5-0.3-0.8V27.7c0-0.1,0-0.1-0.1,0c-0.5,0.9-0.8,1.4-0.8,1.5
+       c-0.1,0.2-0.2,0.2-0.4,0.2C179.8,29.3,179.7,29.2,179.7,29z M207.8,26.7c0,0.3-0.1,0.5-0.3,0.8c-0.2,0.2-0.5,0.3-0.8,0.3h-0.4
+       c0,0,0,0-0.1,0.1c0,0,0,0.1,0,0.1c0.1,0.1,0.4,0.6,0.9,1.4c0.2,0.3,0.2,0.5,0.2,0.8c0,0.3-0.2,0.5-0.4,0.7l-0.9,0.7
+       c-0.2,0.2-0.5,0.2-0.7,0.2c-0.3-0.1-0.5-0.2-0.6-0.5c-0.3-0.5-0.8-1.3-1.6-2.3c0,0-0.1,0-0.1,0c-0.2,0.6-0.7,0.9-1.4,1
+       c-0.7,0.1-2.2,0.2-4.4,0.2h-1.1c-0.1,0-0.2,0-0.2,0.1c0,0-0.1,0.1-0.2,0.2s-0.2,0.1-0.2,0.2c-0.1,0.1-0.1,0.1,0,0.1h8
+       c0.3,0,0.6,0.1,0.8,0.3c0.2,0.2,0.3,0.5,0.3,0.8V32c0,0.8-0.3,1.3-0.8,1.8c-0.5,0.5-1.1,0.9-1.8,1.3c0,0,0,0.1,0,0.1
+       c1.6,0.2,3.3,0.4,5.1,0.5c0.3,0,0.5,0.1,0.7,0.3s0.2,0.5,0.2,0.7l-0.4,1.5c-0.1,0.3-0.2,0.5-0.5,0.7c-0.2,0.2-0.5,0.2-0.9,0.2
+       c-3.2-0.3-6.2-0.9-9-1.9c-0.1,0-0.2,0-0.3,0c-2.7,0.9-5.6,1.5-8.8,1.9c-0.3,0-0.6,0-0.8-0.2c-0.3-0.2-0.4-0.4-0.5-0.7l-0.4-1.4

We want to track SVG files as image, but GitHub shows their diff as text. Any way to hide these SVG file diff automatically? Or way to show them as image as default?

shirakia
  • 2,369
  • 1
  • 22
  • 33
  • http://stackoverflow.com/questions/9794931/keep-file-in-a-git-repo-but-dont-track-changes – houtanb Nov 02 '15 at 15:23
  • Thanks. But we don't want to ignore files themselves. We need to track them but don't want to see diff as text. – shirakia Nov 02 '15 at 15:29
  • Ah. To hide it in github, you might be able to try this [browser extension](https://github.com/matthewrobertson/Github-Collapse-Diff) for Chrome. Here are two in the Chrome store: [one](https://chrome.google.com/webstore/detail/github-diff-helper/dhggdgaoccikibijlbocggphcomehbih?hl=en), [two](https://chrome.google.com/webstore/detail/github-collapse-diff/eenmpdlgpfhmgkkmpjmmchokkmjacaeo?hl=en) – houtanb Nov 02 '15 at 15:33
  • Thanks. Actually I have tried this already and worked nicely. But now it's not maintained totally... (BTW I created a PR for that repo last year). Anyway I can use another Chrome extension thanks. – shirakia Nov 02 '15 at 15:36
  • Ok, sorry I couldn't be of more help. Perhaps someone else who knows github better than I do can provide an answer. – houtanb Nov 02 '15 at 15:40

2 Answers2

2

GitHub does not provide any way to ignore certain files in diffs. Perhaps one day (send a feature request!) they'll build an SVG viewer the way they did for images.

In the meantime, if you also store a rendered copy of your SVG in the repository, you could at least get both views. Credit to HBHB for recommending the Github diff helper and Github Collapse Diff Chrome extensions too. Just pulling them out of the comments for better visibility.

Community
  • 1
  • 1
Kristján
  • 18,165
  • 5
  • 50
  • 62
1

Github now shows SVG and image previews on Files Changed section and its enabled by default:

enter image description here

And you can also hide/show files like this:

enter image description here

Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162