Halt who goes there

Where and how did the phrase "Halt who goes there!" originate?

Halt, who goes there?

It's what a sentry -- someone standing guard -- says to a unknown person who is approaching. At least, that is what the guard says in the movies.