NEW YORK (TheStreet) -- Bill Gates and Warren Buffett have developed quite an affinity for one another over the years. When it comes to investing, they often agree -- but not always.

The first and third richest people in the world, Gates and Buffett have a net worth of $79.2 billion and $72.7 billion, respectively. The former has built his fortune through Microsoft (MSFT) - Get Report  and the latter with Berkshire Hathaway (BRK.A) - Get Report (BRK.B) - Get Report .

The billionaires have joined forces on a number of occasions, from pledging their fortunes to charity to lobbying Congress on immigration. At the 2015 Berkshire Hathaway Annual Shareholders Meeting in Omaha, they competed in a newspaper toss and played some ping pong.

In 2013, Gates called his dialogue with Buffett "invaluable" in an essay penned in the Oracle of Omaha's honor. He also discussed Warren Buffett's methods of investing. "He talks about looking for a company's moat -- its competitive advantage -- and whether the moat is shrinking or growing," he wrote. "He says a shareholder has to act as if he owns the entire business, looking at the future profit stream and deciding what it's worth. And you have to be willing to ignore the market rather than follow it, because you want to take advantage of the market's mistakes -- the companies that have been underpriced."

Gates has likely picked up a few tricks of the trade from Buffett over the years, and there are some overlaps in their investments. At other times, however, they're at odds.

According to data gathered by Stockpickr, Warren Buffett's Berkshire Hathaway portfolio had 47 total positions as of December 31, 2014, with funds valued at $109.4 billion. The Bill and Melinda Gates Foundation Trust was valued at $20 billion, spread across 19 positions.

The billionaires' biggest overlap is on Berkshire Hathaway itself. Warren Buffett just celebrated his 50th year at the helm of the conglomerate, which, as it happens, is Bill Gates' top holding. Class B shares of Berkshire Hathaway comprise 59% of his foundation's public equity portfolio.

The Berkshire shares appear to be coming from Warren Buffett himself. In 2006, Buffett committed to making annual gifts of BRK.B shares to the Bill and Melinda Gates Foundation throughout his lifetime. He made his biggest donation, worth $2.1 billion, last July.

Bill Gates and Warren Buffett have a handful of other stock picks in common as well, including Wal-Mart (WMT) - Get Report. Gates has allocated 5% of his portfolio to the retail giant and Buffett 4.77%.

Walmart made headlines in February when it announced plans to increase wages for about 500,000 of its employees. The increase will cost it about $1 billion a year and should have a relatively minimal effect on its revenue -- a positive indication for shareholders.

Gates and Buffett are also co-investors in Liberty Global (LBTYA) - Get Report, which comprises 0.5% of each of their respective portfolios. Liberty Global is an international telecommunications and television company headquartered in London.

Liberty Global has become the subject of M&A speculation in April thanks to reports of a possible takeover by Vodafone. Analysts claim Vodafone could sell networks in South Africa, India and Australia to fund a purchase. This isn't the first time rumors have surfaced that a deal might be in the works, but so far, nothing has been confirmed.

Buffett and Gates are also betting in beverage giant Coke -- but in different markets. Warren Buffett is one of Coca-Cola's (KO) - Get Report biggest fans. With a 15.4% allocation in his portfolio, the stock is his second-largest holding. The billionaire has described himself on numerous occasions as "one-quarter Coca-Cola," and at the 2015 Berkshire Hathaway meeting, he said he believes that in the years to come, Coke will be even more popular than it is today.

Bill Gates likes Coke, too -- but the division that sells in Latin America. He has allocated 2.7% of his public equity holdings to Coca-Cola Femsa (KOF) - Get Report, a Mexico-based producer and distributor of Coca-Cola products domestically as well as in countries like Guatemala, Costa Rica, Colombia, Venezuela and Brazil.

Warren Buffett and Bill Gates aren't together on everything, though. One area where they're at odds: cars.

In October 2014, Berkshire Hathaway agreed to purchase Van Tuyl Group, the largest privately owned auto dealership group in the U.S., to create Berkshire Hathaway Automotive. "We've gone a long time without getting into automobiles," Buffett said in a CNBC interview at the time, adding he believed Van Tuyl has an operation that "could be scaled up a lot from where it is."

Buffett's Van Tuyl buy puts him at odds with Bill Gates, who owns more than 15% of competitor AutoNation (AN) - Get Report .

Both investments are boding well for Buffett and Gates. The Van Tuyl acquisition, completed in the first quarter, includes 81 automotive dealerships in 10 states and cost Berkshire $4.1 billion. As of March 31, AutoNation owns and operates 282 new vehicle franchises from 232 stores. Its stock has climbed about 4.5% year-to-date.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.