Abstract Proper brain function requires the precise assembly of neural circuits during development. Despite the identification of many cell-surface proteins (CSPs) that help guide axons to their targets 1,2 , it remains mostly unknown how multiple CSPs work together to assemble a functional circuit. Here we used synaptic partner matching in the Drosophila olfactory circuit 3,4 to address this question. By systematically altering the combination of differentially expressed CSPs in a single type of olfactory receptor neuron (ORN), which senses a male pheromone that inhibits male–male courtship, we switched its connection nearly completely from its endogenous postsynaptic projection neuron (PN) type to a new PN type that promotes courtship. From this switch, we deduced a combinatorial code including CSPs that mediate both attraction between synaptic partners and repulsion between non-partners 5,6 . The anatomical switch changed the odour response of the new PN partner and markedly increased male–male courtship. We generalized three manipulation strategies from this rewiring—increasing repulsion with the old partner, decreasing repulsion with the new partner and matching attraction with the new partner—to successfully rewire a second ORN type to multiple distinct PN types. This work shows that manipulating a small set of CSPs is sufficient to respecify synaptic connections, paving the way to investigations of how neural systems evolve through changes of circuit connectivity.