I'm an amateur in this area too, but I'm not suggesting to avoid collisions, I'm suggesting adding a validation function for the hashed data so that if one were to generate an intentional collision, you would still have to contend with generating it in a way that also validated.
For Git, Linus basically says the validation function is a prepended type/length. https://news.ycombinator.com/item?id=13719368