I know giving heads up means to inform someone, but how does that relate to the literal meaning i.e. giving heads up? What's the background? Where did it come from?
It was first used as an interjection in the 19th century: “They marched, and I amongst them, to face the enemy – heads up – step firm – thus it was – quick time – march!”
Then, at the beginning of the 20th century, it began to be used adjectivally, as in: “He was always right on the job, and looking ‘heads up’.”
Then, around the late 70s, it became a noun, probably through shortening of phrases like “heads-up alert” into “heads-up”: “It is regarded as being a heads-up on a sale.”
Source and references: the Grammarphobia blog
Imagine your buddy is next to you and he is reading a book, or looking at something in his hands, or in some other way looking anywhere other than straight ahead. You see trouble coming and you say "heads up!" meaning hey, attention, look ahead! That is the literal meaning of giving someone a heads-up. Over time it's gained a metaphorical one that applies to emails telling someone what's going on, phone calls, and so on.
It's all about awareness.
"Heads up" as an adjective means being aware. "Heads up" as the noun is giving someone new information, making them more aware of the situation. Literally having your head up and your eyes open means you're more aware of your surrounding (contrast with the "heads down" posture of messing with your phone).
So a heads-up display for a pilot helps him keep his eyes open and on the sky instead of down at the controls. Similarly soldiers and sportsmen are more aware of their surroundings with their heads up than looking at their feet.
There's plenty of examples between the 1950s and 1970s of "a heads-up, lightning-swift game", "a “heads up” hockey player", the "heads up organisation", "the "heads up" warning for the hammer throw", "The heads-up, look-ahead attitude", "a heads-up, forward-looking attitude", "A "heads up" industry" and "a heads-up, both-feet-on-the-ground kind of man".
Giving someone a "heads up" is now quite a common term used to give people an update or some form of advanced information. It was adopted from the animal kingdom where taller animals such as giraffes or monkeys and birds who were higher up in the trees gave an advanced warning to other animals on the ground when a predator is approaching. Hence, in today's context, "heads up" means that the person who has the advanced information is giving a brief to those who have not been updated yet about issues that are approaching.
The Wall Street Journal has a good article on the subject, and cites the military and a 1904 article on baseball:
In “John Bumpkin Upon Drill,” a comic theatrical song that the Oxford English Dictionary dates to the 1780s, the title character says, “it were enough to make a cat laugh, to see sarjeant drilling me—‘Heads up! Higher! Still higher!’ ” At the time, “heads up” exhorted soldiers to straighten up and hold their heads high—or more metaphorically, to be courageous and vigilant.
For baseball players around the turn of the 20th century, “heads up” served a more specific purpose: the phrase helped keep the fielding team alert and ready for a ball to come in play. In a 1904 article in the Philadelphia Inquirer, New York Giants catcher Roger Bresnahan recounted that he told his fellow players, “Heads up, now!” before they turned a triple play.
(Looks like the article is behind a paywall... not sure why it let me see the article the first time. Here's the google link that sent me there.)
It seems to have come from the USA. I've not heard English or other British people use it, only Americans.
There is an explanation of it at this link http://www.phrases.org.uk/meanings/heads-up.html , which says "Residents of the USA will have come across heads up as an advance warning; for example, 'The boss was coming. Jim gave us a heads up to get on with some work'. That usage is fairly recent and hasn't yet become commonplace outside America.