When head of government isn't directly commander-in-chief?

In some of the Battlestar Galactica threads in Cafe Society, it’s been debated just how much direct authority President Roslyn has over the military. In the US, the President is explicity given the power of Commander in Chief of all armed forces, but I gather that is not the case in all countries. In some countries, the head of government such as a Prime Minister is deliberately NOT given direct authority over the military supposedly in order to protect the military from being politically interfered with. My question then is, so just how IS the military controlled in for instance the UK? What top eschelon makes the final decisions on how the military is run?

In fact I think the US is unique in among Western democracies in having the head of the armed forces, the head of government, and the head of state all the same person (I assume this is a holdover from the fraught circumstances of her birth) . So perhaps the question is more, how does the US cope with such a concentration of power and not become a dictatorship?

But to answer the actual question, the civilian government still has absolute power over the military, but through civil instruments not military ones. So there is still an equivalent of your Joint Chiefs of Staff, but the head of that body is the C-in-C and he accepts direction from the head of goverment.

The general concept is the goverment tells the armed forces what it wants them to achieve, and they put that into practice. The reality is more complex of course.