Investing in stocks over the long term takes commitment and a strong will to ride out the inevitable ups and downs that the market brings. But if you choose the right companies -- and invest for years instead of months -- the rewards can be huge.

To help you find investments that can go the distance, we reached out to some Motley Fool contributors for three stocks that they think you can buy and hold for the next 50 years. Here's why they chose Alphabet (GOOG -0.21%) (GOOGL -0.30%), General Motors (GM -0.07%), and Amazon (AMZN -0.16%).

A calendar on a desk

Image source: Getty Images.

Don't sweat big-tech regulatory worry

Nicholas Rossolillo (Alphabet): Big technology companies have increasingly come under fire from government regulators. Google parent Alphabet has arguably been one of the hardest-hit, paying out billions to the European Commission over the last few years for various anticompetitive business practices. Increasing calls for regulation have been made in the United States as well, and an investigation into Google and some of its peers is underway. It could take years for a decision to be made, and the final outcome could be wide-ranging -- from increased scrutiny to fines to a potential breakup of Alphabet's empire.

In spite of the tech giant entering regulatory crosshairs and the potential of a forced split in Alphabet's business, history tells us investors shouldn't sweat it. The real reason to invest in Alphabet (as with other businesses that governments have cracked the whip on in the past) is its leadership in innovation; the company has created a culture where technological advancement is pervasive. Simply put, Google isn't simply an advertising business based on internet search anymore.

Sure, about 80% of the Alphabet conglomerate's revenue is still generated by ad sales. But myriad other businesses from data analytics to cloud computing to hardware are expanding fast as well. Then there's the "other bets" segment, a hodgepodge of early-stage ventures and investments that encompass things like self-driving vehicles, space and satellite start-ups, and healthcare. The segment continues to lose money (it lost $868 million in the first quarter of 2019 alone), but Alphabet can afford it. Even when factoring in "other bets" losses and the European Commission fine, operating income was $6.61 billion.

I like Alphabet's strategy of investing huge gobs of cash, from its highly profitable and dominant status atop the digital advertising industry, to foster innovation and growth later on down the road. It's a farsighted vision, one that makes this stock worth holding for the indefinite future -- even if government regulation poses a near-term threat.

No driver, no worries

Daniel Miller (General Motors): One unusual stock that you can buy and hold for 50 years is General Motors. You may be skeptical, but hear me out. Right now seems like a horrible time to invest in a Detroit automaker, as sales of light vehicles in the U.S. plateau, but the cyclical nature of the automotive business doesn't matter over a 50-year time frame. Furthermore, one could argue that GM's price-to-earnings ratio of 6 makes this a great time to invest, as much of the near-term negativity seems priced in.

GM is also well-positioned to carve out a leading position in driverless vehicles, as that opportunity continues to expand over the next few decades. Take GM Cruise, for instance: Acquired as Cruise Automation in 2016 for around $600 million, the subsidiary has soared in valuation and gained plenty of attention. In May GM announced that SoftBank, Honda, General Motors itself, and scattered institutional investors invested an additional $1.15 billion in Cruise at a post-investment valuation of $19 billion -- an impressive valuation boost in only three years.

The increasing number of GM Cruise investors and partnerships is hugely important: The company announced in March that by the end of 2019 it would double its employee headcount, from roughly 1,000 to 2,000, as it drives toward the commercial launch of a ridesharing service in San Francisco later this year.

The bad news is that because driverless cars could be a lucrative opportunity, the competition is intense, but the technology is expensive to develop. The good news is that despite slowing U.S. sales, GM has focused on more profitable full-size trucks and SUVs, which boosted its average transaction prices (ATPs) by $1,575 during the second quarter to $37,126 -- excellent compared to the industry average of $33,681, according to J.D. Power PIN (Power Information Network) estimates.

Time will tell if GM can indeed succeed with its ambitions. But considering its paltry P/E of 6: If you have a long-term time frame that makes investing in a cyclical business less risky, and believe in its driverless-vehicle potential, GM could be a great stock to hold for 50 years.

An e-commerce play and cloud computing play rolled into one

Chris Neiger (Amazon): If you want a company that will have no problems adapting to shifting trends over the next five decades, look no further than Amazon. It's best known for its e-commerce dominance, of course, and this year it's expected to account for about 38% of all online sales in the U.S.

Don't think that Amazon's finished growing this business, either. Its recent shift toward one-day shipping for Prime members is aimed squarely at keeping its e-commerce rivals at bay. Additionally, its recent Prime Day was a smashing success, with 175 million items sold in just two days. Amazon's early lead in this space means that as the worldwide e-commerce market grows to $4.9 trillion by 2021, the company will continue to benefit.

But it's not just e-commerce that'll keep Amazon humming along in the coming decades. The company's lucrative Amazon Web Services (AWS) cloud computing platform will help as well. The majority of Amazon's profit already comes from AWS, and as the leading public cloud computing company, with market share of over 32%, Amazon is more than ready to stay ahead of Microsoft and Google in this space. Considering that cloud computing will be worth $331 billion by 2022, Amazon is just getting started in this massive market.

All of this means that if you're keen to pick a stock and keep it for decades, without having to worry if it's well-positioned to keep growing, you can buy Amazon and hold it for the long haul.