Slice hoagie rolls about three-quarters of the way through using a serrated knife. Dice the onions and slice the beef thinly.*
In a small bowl, mix 2 Tbsp softened butter with 1 pressed garlic clove. Spread the garlic butter on the cut sides of the hoagie rolls.
Toast the rolls on a skillet, flat cooktop, or griddle over medium heat until golden brown. Set aside.
Add 1 Tbsp oil to the pan and sauté the diced onions until soft. Lightly sprinkle with salt and cook until caramelized, then transfer to a bowl.
Increase heat to high and add 1 Tbsp oil. Spread the thinly sliced steak in an even layer. Let it brown for a few minutes without stirring, then flip and season with 1/2 tsp salt and 1/2 tsp black pepper.
Cook until the beef is fully done, then stir in the caramelized onions.
Divide the mixture into four portions and place two slices of cheese on top of each. Turn off the heat so the cheese melts gently without overcooking the beef.
Spread a thin layer of mayonnaise on the toasted side of each roll. Working with one portion at a time, place a roll over the beef and cheese, and use a spatula to scrape the mixture into the bun. Serve warm.