The geodesics are the shortest curves that can be drawn between two points in a space. If the surface is a spherical one on which we are trying to get the geodesic between two points then it is said to lie on the largest circle passing through the two points that can be drawn on the spherical surface and it's dubbed as great circle. To prove the thing the way I thought was driven by the approximation that tiny pieces or parts on the surface of sphere can be treated as being Euclidean (I may be wrong using the word, the thing I mean to say is that I can use the Pythagoras theorem up there). So if I define a coordinate system much like that on earth the latitudinal-longitudinal $(y-x)$ [such that the two points let's call them $P1$ and $P2$ lie on the curve $y=0$ ] so in tiny spaces I can treat it like being Euclidean (I can use Pythagoras theorem) so the distance measured moving along the curve $'S'$ is the summation of small changes in $S$ with respect to small changes in the $x$ and $y$ . So my approximation allows $(dS)^2= (dx)^2 +(dy)^2$ It will be how the function goes And $dS$ will be greater than or equal to $dx$ and thus the $dS=dx$ or $dy=0$ for having $S$ as minimum. And thus $S=ndx=x$ and it lies on the great circle as we have designed the system of coordinates. So my question is what is the other way the above thing can be proved or more generalized way (better if without the above approximation) and which can help to get a general property of a geodesic on any surface ?
(I checked a question first a bit similar one but I didn't understand the notations used there a comment on the question or any link will too be helpful)