I've actually tangled or had run ins with hogs a couple times. It was never random, or truly initiated by the pig. Each time it was a wounded, cornered, or trapped pig- so not their fault.
That being said- if you can't climb something, put a tree or even some brush between you and them. Best if you can see over/around it. I don't think their vision when running/charging is great, and I've never had one follow me around an obstacle- they just run by.
Also, their lateral movement sucks if they are running forward. So, you can side step them pretty easily, just keep your nerve and time it.
If you HAD to go hands on, know that you are probably going to get cut/bit. Just know that. Yes, a boar with big cutters can mess you up, but don't sleep on a sow either. You'll be likely able to operate and fight through the initial contact. I wouldn't recomend trying to pull out a pocket knife and fight- you aren't going to hurt them enough. Maybe with a big Crocadole Dundee knife.
Instead, I would try and get their back legs. I was able to side step a charging sow once, and as she stopped to turn. I grabbed her back legs and hoisted them off the ground. That took her motor away. I pushed her over to some brush (so she had an escape route), and waited for her to start trying to pull away. Once I let go, she was more than happy to skedadle.
All that to say- don't overthink this. 1) It isn't likely to happen with a random pig in the wild. 2) It's not like fighting a bear. Just stay out from directly in front of them, fight like hell if you need to, or get there back legs.