Sun Tzu's The Art of War suggests a "Stern Father" approach to leading one's men. One commentator relates a story of a general who personally cared for an ill soldier. When the soldier's mother heard of it, she burst into tears: her husband, who served the same general, never abandoned the man afterward and died in battle as a result—and now her son was going to be the same way.
Lampshaded in Dune when Duke Leto Atreides risks his life and the priceless spice to save his men, someone comments that a man such as that would inspire fanatical loyalty. It's implied that this is why the Emperor wants him dead, because he fears Leto will use his popularity to depose him.
See also Miles Teg, a descendant of Leto Atreides 5000 years later. While his actions are never gone fully into detail, he is so like Leto that even an awakened Duncan Idaho ghola is driven into fanatic loyalty, seeing the same Atreides core of integrity. The fact that the genetic dice have given him almost exactly the same appearance does nothing to diminish this effect.
An almost inadvertant example of this trope is Metellus Pius (aka 'the Piglet') of Colleen McCullough's Masters of Rome series. He fusses and clucks over his troops more like a mother than a father to make sure they are in fighting trim when the time for action comes. At first his motives are purely practical but the glow of his men's gratitude and affection gradually changes that. In the end he cares for 'his boys' as they care for him.
Aral Vorkosigan, specifically how he treats his men during the two pre-Miles books, Shards of Honor and Barrayar, by Lois McMaster Bujold. He's explicity said to love Koudelka "like a son", bending the rules to keep him on as a secretary when he would have been medically discharged. If one applies this metaphor to Bothari... a little Oedipal complex? That's sorta scary how well it fits, especially his incident during the Escobaran war...
Bujold loves this trope: she also used it in Paladin of Souls - Lord Arhys is just such a man, and it is outright stated that his patron god (the Father, natch, one of the five gods) feels the same way about him. So much so, in fact, that his soul is taken up by the Father despite never having fathered a child.
He did have a daughter by his first marriage.
Lord Suffolk in The English Patient is like this, especially for Kip, who considers the English sapper unit to be his real family. This is a definining feature in his backstory.
Star Wars Expanded Universe: Kal Skirata was the only family his clone troops ever knew, and he did care about them as though they were his children; he allowed his own sons to disown him, in order to keep the clones safe because they needed him more.
A rare literal example later on: he formally adopts the main characters as sons near the end of the war.
Despite what Karen Traviss wants you to believe, the Jedi were as fathers to their men, the Clone Troopers, despite their origin. They treated them well, giving advice, etc. Many willingly sacrificed themselves to save their Clone Troopers. The only Jedi that acted like they were expendable slaves were the ones who were falling or who already fell to the dark side.
While it doesn't come off so much in the movies, in his own way Darth Vader is like this to Imperial troops. Unlike many other commanders, Vader would fight on the frontlines with them, not expect anything from them he wouldn't do himself and was generally a very strong guarantee of success in most of the battles he led.
Thrawn, having realized that the Empire remnant no longer had reserves, became a respected - if somewhat ruthless - leader to his men, trying to spare them whenever he could and heavily reprimanding his commanders for losing them fruitlessly.
And Polly's own motherlynature shows throughout the book, often landing her in charge even when she's not technically in charge.
Commander Sam Vimes. "When your back's against the wall, Mister Vimes is right behind you."
Capt. Aivars Terekhov in the Honor Harrington spinoff The Shadow of Saganami is the textbook example, strict and caring at the same time, and even complete with the Bad Dreams.
Honor herself is clearly a mother to her men, albeit a properly distant one in the military sense (but definitely capable of being a Mama Bear if anyone harms them).
From Robert A. Heinlein, there's Rhysling's infamous song "The Captain is a father to his crew", which should never be sung in mixed company.
Dan Abnett's Warhammer 40,000 series Gaunt's Ghosts had Colonel-Commissar Gaunt of the Tanith First-and-Only in this role, but Colm Corbec, Gol Kolea, and to a lesser extent Viktor Hark all exhibit signs of this.
In The Guns Of Tanith, several people try to persuade Gaunt this it is beneath his dignity to involve himself in the question of whether a Ghost trooper accused of rape and murder is guilty. He counters with the fact that the troopers actually win his battles, and a general is impressed by such views, which he hasn't heard in some time.
Some subordinates also show it. In Straight Silver, Raglon is deeply guilt-stricken when his first mission as a sergeant results in half his troopers dying. When Gaunt's reassurance reveal that Raglon is hiding something, and Gaunt digs for it, Raglon tries to put him off with, "I was in command, sir" before telling Gaunt that Costin had been drunk, and then tries to save Costin from Gaunt.
In His Last Command, Wilder also fits under this trope, suffering somewhat because good as he is, he is not Gaunt. And Mkoll, seeing a scout whom he met only recently knocked through a Chaos warp gate, says No One Gets Left Behind—and jumps through. Despite its being cold and wrong on the other side, and the other scout's freaking out, he gets him back to safety.
However, whether Ciaphas Cain is a true father to his men or not is a matter up to debate, though considering how many times his biographer notes he followed this trope when being coldblooded would be more rational, signs point this being true.
One can at least argue that he makes a good example of why a commissar that encourages his men through care rather than fear is more effective. As he himself states, commissars who use fear to boost morale are for some reason more susceptible to "accidents" from his subordinates, which in turn would plummet morale to oblivion in the end.
At the same time, he is so oblivious to how beloved he is by his men - and indeed most of the Imperial Guard - that, when an assassin tries to kill him, he points out that it would have made more sense to kill other officers or the Planetary Governor - not realizing that his death would be devastating to morale.
The trope is mentioned in one of the Flashman novels, which the Cain series is strongly based on. On the eve of the Mutiny, an Indian sepoy says that his old commanders said their soldiers were like children to them (in a good sense), not like the arrogant idiots now in command.
The commander's grief was absolute. He had loved Sejanus like a son.
In Mitchel Scanlon's Descent of Angels, when Brother Amadis tells Zahariel he had saved his friends, Zahariel tells him he was protecting his squad, and then tries to fight off collapse on the ground he had to get the squad back. Amadis assures him that he will take care of it, as Zahariel's done enough.
Admiral Cyrus Stableford in Tranquilium. Possibly even more so, Gleb Marin later in the novel (especially when he becomes the Tsar of Palladia). The latter actually muses in some detail on how this is a necessary component of good leadership, and makes sure to cultivate a strong bond with those under his command. Both have highly loyal crews and/or troops that support them through the political thick and thin.
In the Malazan Book of the Fallen, Dujek is portrayed as this. Like Adjunct Lorn points out, "He's not just a man. He's ten thousand men and in a year's time, he will be twenty-five thousand men". Whiskeyjack as well, to the Bridgeburners.
Not the case with Horatio Hornblower, who attempts to maintain proper distance and reserve between himself and his crew. They worship him anyway, because he's absolutely fair to them, and utterly brilliant in battle.
The title character of "Leiningen Versus the Ants", despite not being military. Even facing a gruesome death from a giant art swarm, Leiningen's plantation workers refuse to abandon him, even when offered an escape route and their full pay to take it. When their only hope comes down to a suicide mission Leiningen takes it upon himself rather than having one of his men attempt it.
Dalinar Kholin and Kaladin from The Stormlight Archive. Also, Dalinar is attempting to train his son Adolin to be this.
Subverted in The Forever War by Joe Haldeman. The protagonist tries to fulfil this trope when he becomes a major but fails, partly because he's not suited to the role but mainly due to Time Dilation he's a relic from the past who doesn't understand the language and culture of contemporary humans.
Gaius Marius is one to the Primigenia in Emperor: The Gates of Rome. A couple of his legionaries even explicitly refer to him as a father figure.
In David Drake's Northworld trilogy, Hansen blames himself for the deaths of anyone who fought on his side — because either they died following his orders, in which case he got them killed, or they died not following his orders, in which case he got them killed by not being able to make them see that what he ordered was the right thing to do.
In Robyn Johnson's Vara , Commander Hyde is this though it's most notable with the female Lieutenant Hart. Commander Jax was this with his soldiers as well, even going so far as to die alongside them
General Belisarius in David Drake and Eric Flint's Belisarius novels is this, right down to the military genius part.
The Colonel in George MacDonald Fraser's McAuslan, a quiet old man who refuses to allow his men (even the worst disciplinary problems) to be punished outside the battalion, attends all their activities, and is proud of their least successes.
In Andre Norton's Ice Crown, one of Imfray's men, after the rescue, recounts the time Imfray saved him from a rock fall.