What does it mean if a guy pats your head?

A guy friend of mine which I've known for a couple of years patted me on the head, he made a joke and he was then like 'Oh' and patted me on the head. Why would a guy do this?

I mean I know he had a thing for me a couple of years ago, but I didn't realise it so I lost him and now he has a girlfriend. For this reason I don't think he was flirting but at the same time I don't know what other reason there could be.

So why would a guy pat a girl on the head?
What does it mean if a guy pats your head?
Post Opinion