In a small pan, cook the mushrooms, onions, and garlic in the olive oil over medium heat. Season with a little salt and pepper and cook until well browned. Set aside.
In a large mixing bowl, combine the shredded potatoes, mushroom mixture, eggs, sour cream, cream of mushroom soup, 3 ounces cheddar cheese, and 1 tablespoon chopped rosemary. Stir to combine. Spoon into a 9x13-inch baking dish. Top with the remaining cheese and rosemary.
You can prep this the night before, cover well, and refrigerate overnight. Then bake in the morning before serving.