Onions and garlic can be planted together. Both are ready to harvest around the same time, and both repel plenty of unwanted pests and insects. Be careful though with planting all of your onions and garlic together, as onion maggots can travel easily from plant to plant. If you end up with an infestation of onion maggots and all of your onions and garlic are planted together this could result in a total loss of both crops.