“Sheepdog” can refer to much different breeds, ranging from collies to Maremmano, all with with different temperaments, behaviours and “jobs”.
To understand how a sheepdog will behave around the herd and in case of an encounter with a predator such as a wolf, it helps to clarify the difference between herding dogs and livestock guardians, as these types have been selected since old time and differ very much in their drive, behaviour and training.
Herding dogs cooperate with the human herder to control and direct the movement of the herd or flock. The typical way in which they work – the staring, the postures, rounding up the sheep or cattle – is based on their natural prey drive, with some inhibitions at play to prevent them from harming the herd or flock.
[The Border collie stance and stare, known as “the eye” – Image source]
[Australian koolie herding merinos – image source]
In a way, they behave like their ancestors, wolves – except they’re on the herder’s side and are his (her) most loyal partners. Herding breeds are typically highly energetic, intelligent and collaborative: they work in close contact with the herder and a good herding dog has to be very well-attuned with its human partner. Communication between the two is the basis of their partnership (this is also one of the reasons why herding dogs have become very popular family dogs too).
Often, herding dogs breeds are specialised to herd either cattle or sheep. Cattle dog breeds tend to be smaller, as this helps in preventing injury (being kicked by a powerful cow when nipping at the heels, for example), while herding dogs that work with sheep tend to be larger.
[Corgis were originally bred to herd cattle: that’s why they’re short and prone to biting your ankles – image source]
By contrast, traditional livestock guardian dogs do not work in partnership with a herder. While herding dogs behave like wolves (outsiders) who cooperate with the herder, livestock guardians are insiders, they belong to the herd/flock and act as its protector. They do not rely much on the herder, though.
As such, livestock guardians tend to have a different temperament compared to herding dogs: they are often fiercely independent and self-reliant (to the point of coming across as aloof), highly territorial and are expected to be aggressive towards outsiders (but displaying no prey drive towards the herd or flock).
Physically, they also tend to be very large and intimidating, as they were bred to defend the herd from predators such as wolves and leopards.
[Bosnian Tornjak, a Balkan breed of livestock guardian – image source]
[Tibetan mastiff portrait, a typical livestock guardian – image source]
So, how do these different types of sheepdog react to a wolf?
In the case of a properly raised livestock guardian, the dog will scare away the predator(s) and alert the humans (who will intervene), but it won’t abandon the herd/flock. This detail is crucial. A bad guardian dog will chase and pursue the fleeing predators, a mistake wolves quickly learn to exploit, as while the dog is in pursuit of one or a few of them, the others will attack the flock (sadly, this happen with improperly trained guardians). As I said before, the proper place of a livestock guardian is with the animals it is guarding.
What about herding dogs instead? My experience is limited, because in the places where I’ve observed herding dogs at work there were no wolves. However, I imagine two scenarios based on their typical temperament: the herding dog alerts the humans (which is the most sensible course of action) or the herding dog pursues the predator.
The latter will probably not end well for the dog (and possibly the flock) as even a large herding dog is no match for an adult wolf (let alone a pack). I reckon if such an encounter ended with the dog still alive would be because of the wolf’s reluctance to approach, not because the dog could in any way fend it off on its own. Herding dogs are generally slender and smaller than wolves (even a German shepherd, one of the largest, would be no match).
Said so, the dog’s response to the presence of a wold will depend on many factors, not just its breed: its own individual temperament and personality, its experience (including both its training and its previous encounters with predators), the relationship it has with the sheep and the humans, etc.
In other words, you can’t simply buy a pedigree sheepdog puppy and expect it to know what to do (sadly, I know of situations where this has happened, with disastrous results). Herding dogs need to be be trained and livestock guardians learn especially from their mother and other adult guardian dogs they live with. This is important to keep in mind.
If you have sheep and are concerned about wolf attacks and need a dog to protect them, the most suitable type of dog would be a guardian (or more than one, possibly litter mates). Said so, it will take a considerable investment in terms of effort and time, especially if you have no previous experience, in that the dog(s) will need to be properly introduced to the flock as a puppy and trained properly. The last thing you need is a guardian who doesn’t recognise the flock as its family and displays predatory behaviour towards the sheep.