The Answer
They can’t.
In was once thought that porcupines can propel their quills at an attacker (or unfortunate bystander) to defend themselves. In fact, porcupines are not able to shoot their quills.
Although porcupines can’t shoot their quills like arrows, the quills do detach easily. If a predator were to attack a porcupine, the slightest touch can lodge dozens of quills in the predator’s body.
The belief that porcupines can shoot their quills may come from the fact that when threatened a porcupine may quickly jump at their attacker to skewer it with it’s protruding bristles.
The Latin name of the porcupine joins the word porcus meaning hog or pig, with spina meaning thorn or spine. Porcupines are sometimes colloquially known as quill pigs.