The attraction and repulsion is based on the mediator. If the mediator boson spin is odd, like the gluon, you get like charges (color) repel, and opposite charges attract.
Now this strong force is very distance dependent, because it is not always attractive. I actually asked a question about this.
The strong force does pull quarks together, but it also gets weaker as the quarks get closer (i.e. it acts sort of like a spring), in a phenomenon known as "asymptotic freedom." In this way, the strong force is very different than electromagnetism, where the force gets stronger if the charges are closer together. As such, there's no reason to expect that quarks which are placed close together will immediately annihilate, as there's just not a lot of force on them in the first place.
Quarks don't exist as free charged objects on which we could take the classical limit and consider "forces" on them. They are confined, and occur only as constituents of bound states. In quantum mechanics, it doesn't make sense to ask whether the constituents of a bound state "repel" or "attract" each other.
So basically we cannot experimentally tell whether two quarks would repel if they had same color, but theoretically they would (because of the odd spin of the gluon).
Quarks of different color experience an attractive force between them; whereas quarks of a like color repel each other.