"When you think about the resources that would have been needed to have a full lineup there, with no clear profitability in sight, we had to be real about that," said GM President Mark Reuss, among Ms. Barra's most trusted lieutenants.

Eventually, the retreats from international markets resulted in a hangover effect, former executives say. Some costs attached to those severed business units remained even after the divestitures -- a Detroit-based engineer or designer who worked on cars for developing markets, for example.

Late in the summer of 2018, a few hundred of GM's top executives gathered at a historic brick building in Flint, Mich., GM's first factory. Ms. Barra dispatched her then-finance chief, Dhivya Suryadevara, to warn that cost cuts would be needed, people who attended the meeting say.

On Thanksgiving weekend that year, GM announced plans to let go more than 8,000 white-collar workers, the cuts hitting the engineering ranks hard. The company also outlined plans to close several North American factories and let go thousands more factory workers, which drew sharp criticism from President Trump.

Ms. Barra in the interview said the changes were strategic and allowed GM to meld its electric-vehicle team with the broader engineering enterprise.

Both pieces of Ms. Barra's two-pronged strategy -- exiting low-growth businesses while plowing the capital into an electric future -- were on full display early this year.

In February, GM said it would end its Australian Holden brand, a once-dominant brand and staple of the country's car-crazy culture, known for rugged pickup trucks and muscular sedans.

In Australia, car enthusiasts and politicians vented a sense of betrayal.

"General Motors may think the rich history of the Holden brand in Australia is worthless, but I think it's priceless," said one lawmaker, Queensland Sen. James McGrath, according to Australia's Courier-Mail newspaper.

Then, in early March, GM invited hundreds of dealers, analysts and journalists to its suburban Detroit engineering center. Ms. Barra made her biggest statement yet that GM was betting its future on electric cars.

The CEO strolled the floor as visitors ogled a dozen future all-electric models, some several years from seeing the inside of showrooms -- a rarity in an industry where future products are cloaked in secrecy. The models ranged from brawny pickup trucks to a Cadillac that one executive said would be priced above $200,000.

GM said it would spend $20 billion developing electric and driverless cars through mid-decade. It is targeting sales of 1 million electric-car sales annually by then. In Ohio, near a factory it closed last year, construction began recently with partner LG Chem on a battery-cell plant bigger than 40 football fields.

Still, it will be many years before electric vehicles take off, analysts say. High battery costs are likely to keep prices higher than conventionally powered cars through most of this decade, and a dearth of charging stations in the U.S. will dampen consumer interest, they say.

So far, the early offerings from incumbent car companies have failed to achieve anywhere close to Tesla's success.

As Ms. Barra showed off GM's future battery-powered cars, she was also confronting a new threat: a rapidly-spreading global pandemic. GM spent the spring scrambling to borrow more than $20 billion amid a multiweek factory shutdown from Covid-19, during which it bled billions in cash.

In June, Ms. Barra sat with top executives inside GM's design dome, a circa-1950s auditorium where generations of leaders have reviewed big Cadillac sedans with gaudy tail fins and Corvette sports cars.

This meeting was different: Ms. Barra and her team sat at a large table, wearing masks, to decide which future vehicles were on the chopping block. Details of each model, from minor face-lifts to major new entries, were spread across large digital wall charts, including launch dates and sales targets.

Some were delayed, others scrapped altogether. By the end of the meeting, all of the electric-vehicle projects on the board emerged untouched, along with a nearly $3 billion renovation of a Detroit factory and nearby facility to build them, Ms. Barra said.

"The situation allowed us to look at things with a very clear eye," she said.

Write to Mike Colias at Mike.Colias@wsj.com