Add potatoes, cabbage, garlic, and bouillon cubes to a large pot of water and boil until potatoes are fork-tender, 20-25 minutes.
Drain completely and return to pot.
Add cream cheese, milk, butter, sour cream, salt, and pepper to the pot.
Mash everything together until creamy with some texture remaining.
Preheat oven to 350F.
Transfer mixture to a greased 3-quart casserole dish and cover with foil.
Bake for 45 minutes, removing foil for the last 10 minutes for a golden top.
Garnish with chopped green onions if desired.