Preheat your oven to 375°F (190°C).
Grease a large baking dish with butter.
Layer half of the sliced potatoes at the bottom of the dish.
Sprinkle half of the chopped onion and garlic over the potatoes.
Season with salt and pepper.
Pour half of the heavy cream over the layer.
Add half of the cheese on top.
Repeat the layers with the remaining potatoes, onions, garlic, cream, and cheese.
Cover the dish with aluminum foil and bake for 40 minutes.
Remove the foil and bake for an additional 20 minutes until golden and bubbly.