Why may geodesic not be the shortest path on a surface?

As said in Geodesic in Wikipedia:

In metric geometry, a geodesic is a curve which is everywhere locally a distance minimizer

but implied that it doesn't have to be the shortest path, so in brief why does it minimize all local distance on its path, but does not minimize the total length? Is that something like greedy algorithm?

• Think about two nearby points on a great circle on a sphere. There are two geodesic joining them and only one of them truely minimize the total length. Sep 13, 2015 at 2:39
• Yes but what's the internal reason of that? It does minimize the local distance, do you mean that the length difference occurred because of the initial direction difference? Sep 13, 2015 at 2:41
• Another example: take two points in a cylinder (one exactly above the other), which has helices, horizontal circles, and vertical lines as geodesics. You can join them by a suitable helix, but the shortest geodesic will be the vertical line segment joining them. Sep 13, 2015 at 2:41
• @IvoTerek: so what does 'locally a distance minimizer' really mean? Sep 13, 2015 at 2:44
• Given a point $p$, there is a neighbourhood of $p$ such that if you go from $p$ to another point $q$ in the neighbourhood by a geodesic which is contained in the neighbourhood, then the geodesic minimizes length over all curves from $p$ to $q$ in the neighbourhood; Sep 13, 2015 at 2:49