Preheat your oven to 375°F (190°C).
In a large skillet, melt the butter over medium heat. Add the chopped onions and cook until translucent, about 5 minutes. Stir in the minced garlic and cook for an additional minute until fragrant.
In a mixing bowl, combine heavy cream, salt, and pepper. Stir in shredded cheddar cheese until well blended.
Arrange half of the sliced potatoes in a greased 9x13 inch baking dish. Pour half of the cream mixture over the top, spreading it evenly.
Add the remaining potatoes on top and pour the rest of the cream mixture. Gently tap the dish to settle everything.
Cover the baking dish with aluminum foil and bake for 30 minutes. Remove the foil and bake for an additional 30 minutes, or until the top is golden brown and the potatoes are tender.
Let the dish cool for 10-15 minutes before serving, allowing the sauce to set.