Depending on what you mean by "wiring a head unit without a harness," there are a couple ways to solve the problem. If you have the factory wiring harness, but not the harness that came with your head unit when it was new, you can either purchase an adapter (if one is available) or make one yourself.
If you have everything that came with your head unit, but someone at some point cut the factory wiring harness out of the car, all you need to do is identify the wires and solder them into your head unit. However, if your head unit doesn’t have a wiring harness and you’re working with bare wires in your car, that’s a more involved, but still doable project.
While head unit harness adapters allow for plug-and-play head unit installation, it’s relatively common for installers to cut the factory harness and solder the head unit harness during installation. If that head unit is later removed, you’ll be left with bare wires, or if you want to upgrade to a new aftermarket head unit, you’ll be forced to cut the aftermarket harness and start over.
While it may seem daunting to look into your dashboard and see a wild tangle of wires, this problem is relatively easy to fix. The best solution is to obtain a wiring diagram for your make and model of car, or search online for a diagram or chart that shows which wires do what.