Hang in there

What is the origin of "Hang in there"?

I confess that I have not researched this. It sounds much like the exhortation to "hang on" or "just hang on," and the meaning is the same, as far as I can tell. It means persevere, or don't let the bastards grind you down, or keep the faith, or whatever variation on persevere suits the circumstances.
SS