Take the 2-minute tour ×

I committed a few PDF files into a git repository and it looks like git treated it as text and not binary. So what's in the repo is almost 1k larger than the source and no longer displays correctly.

I updated my .gitattributes file to include PDF files as binary, but the damage already seems to be done on the files in the repo. Is there any way to tell git to re-add the PDFs as binary? Would be best solution be to remove the files from the repo and re-add them?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

yes, remove and add back should work.

Committing a new version on top after you've added the .gitattributes file should be enough. The removing step should not be required.

share|improve this answer
Could you please elaborate on this? Why should OP do this? What benefit does it bring as a solution? What are some pros/cons to this solution? –  Benjamin Gruenbaum Feb 14 '13 at 23:24
the file is corrupted in git anyway. committing a new version on top of the corrupted one may work now that he has the proper .gitattributes, but I'd personally prefere to start afresh. –  Pascal Belloncle Feb 14 '13 at 23:26
I was referring to the quality of your answer, a user might get here from google a year and not understand the reasoning behind your answer. –  Benjamin Gruenbaum Feb 14 '13 at 23:27
Understood. I've updated my answer, with a slightly different view, as removing is not really necessary. –  Pascal Belloncle Feb 14 '13 at 23:38
Even though I said it in the question, it didn't actually click that the file is already corrupted! Removing and re-adding is what I'll do. –  Andorbal Feb 14 '13 at 23:40
add comment

Your Answer


