As much as I love dogs and don't condone violence towards them you do have to defend yourself if attacked. If you can get away then fine but if you can't then you have to do what you can.
I have only been badly attacked by a German Shepard once when I was out walking my dog. It was tied up outside a shop and it managed to snap its lead to run at me. The GS attacked me not my dog btw. I tried punching it on the nose, no effect, booting it in the groin, no effect, slashing at its eyes with my bunch of keys, no effect, a sustained punching at it's eyes and nose while booting in the groin, no effect.
The GS only stopped when the owner came out of the shop and called it off. They then went off in the opposite direction without even checking to see if I was ok. No one else checked either. My own dog was terrified and hiding behind me all through the attack.
Aside from that attack I have still been quite happy to stop and talk to dogs.
I found a huge Rottie, my neighbour's, busy stopping people from getting out of a minibus taxi by standing there growling at the bus. It was only because the taxi stopped outside the Rottie's house. I just went over and had a chat with the Rottie and told him to go home and eventually he left and the people got off the minibus. So generally dogs are only guarding their territory.