It's different for every business but typically a CEO is the visionary, strategic leader of the company while the president leads the day-to-day operations.
If Github started selling insurance, there's a good chance they would have a president for Github Code and a president for Github Insurance. They wouldn't have two CEO's, though.
I know SC2 is probably a poor example but it fits very well here. It's the difference between managing a team strategy in an RTS versus looking at the individual unit deaths/spawns, types of units, etc.
The two are similar, and you'll often see them combined. For the most part, president pre-dates the CXO nomenclature. Before there were CEOs, COOs, and CFOs, there were Chairmen, Presidents, and Treasurers. Those titles/roles still exist, but are often merged with CXO functions.
While there are a lot of responsibilities that might vary company-to-company, the CEO reports to the Board of Directors (who represent the shareholders). Shareholders have control over the company because they can elect the Board of Directors (and depending on structure the CEO). The board has control because they get a vote on important matters like major officers and big expenditures. Depending on structure, they may elect the CEO. In the case of Github, it looks like the transition was driven by a friendly consensus of everyone involved. The CEO may need to get Board approval for changes in major officers, acquisitions, and major expenses, but they have the most control over those aspects, and thus the high-level corporate direction.
Because the CEO represents the shareholders, legally his or her main job is to protect the interests of the shareholders. For a public company, the CEO is the one sweating the most about the stock price; for a private company, the CEO is usually responsible for raising investment and driving the financial structure of the company. If someone is a potential investor or acquirer, they will be working with the CEO. Because they're selling the vision of why the company is a good long-term investment, the CEO tends to be the voice of the long term strategy.
The president may still have some of those responsibilities, but in most cases is less directly involved in fund-raising and more focused on the day-to-day operations.
That said, there are a number of other responsibilities around direction, operations, hiring, etc that can be split between the president and CEO.
The CEO most certainly does not represent the shareholders. The shareholders elect a board to represent them. The CEO represents the company's management, and is responsible for attaining the goals the board sets for him/her. It's worth pointing out that those goals aren't necessarily getting a high stock price or maximizing revenue. Lately, there have been a number of companies that set goals that have more to do with social goals than specific financial goals.
Sorry, it should have read: "Because the CEO represents the interests of the shareholders".
While the CEO is not (absent other roles) a representative of the shareholders (as you pointed out), there is a legal duty of loyalty to act in the best interest of the shareholders.
So while not a representative of the shareholders, the CEO is always responsible for representing the interests of the shareholders.
As you stated, those goals aren't necessarily related to the stock price or maximizing revenue. However, if the interest of the shareholders is something other than those goals, the CEO still has a legal fiduciary responsibility to act as a representative of the shareholder interests that do exist.
I suppose that's true in principle. But in practice, the CEO has to be pretty flagrantly acting against the shareholders' interests (embezzling, "cooking the books", etc) to be held legally liable. The case law here is predicated on the belief that "judges are not business experts", and I agree with that sentiment. Courts shouldn't be telling company management what is and isn't in their shareholders' best interests. It's up to corporate management to make that determination, and that's the way it should work.
Quite right it is the chairman of the board (or in this case the president) who is effectively the boss of the C levels and its the boards responsibilities to look after the share holders a CEO/COO/CFO is just another worker.
It's a good question, as it's a very vaguely defined job title, but generally the CEO sets overall vision, and managing the board, investors, etc (i.e. external facing) - and the President focuses on execution of that vision (i.e. internal facing). President/COO are interchangeable in this case.
Think about Facebook: Zuckerberg sets direction/vision, and Sandberg executes against that. (I'm sure it's not as clear-cut in reality, but you get the idea.)
In some larger companies, there are multiple presidents with responsibility for their own divisions, who all report up to the CEO.
That's really the question when it comes to having a separate president and CEO role (and often times having a separate CEO and chairman role). Who's really in charge, and what does the person who's not in charge do? There really isn't a good way to tell. Generally, it's either a sign that:
1. The President is being groomed for the CEO position once the "real" CEO leaves (such as Tim Cook).
2. One of the two needs to give up their position, but isn't because either nobody wants to force them out or they're too powerful to be forced out.
3. The company is so huge, the CEO needs to delegate some of their authority.
My money's on #2. Tom Preston-Warner clearly doesn't need training to be the CEO, and github clearly isn't big enough to need separate CEO and president roles.
If Github started selling insurance, there's a good chance they would have a president for Github Code and a president for Github Insurance. They wouldn't have two CEO's, though.