Add the oil to a frying pan, and heat to medium. Add the onions, and cook for 1 hour, stirring frequently until they turn golden brown and become caramelized.
Preheat the oven to 350 F. Shred the cheese, and set aside. Melt the butter in a sauce pan over medium heat, and add the garlic, salt, and pepper. Combine the caramelized onions with the butter mixture.
Cut the bread with a serrated knife, slicing on the diagonal about 1-inch apart, but not cutting all the way through. Turn the bread, and cut crosswise over the existing slices to create 1-inch diamonds.
Separate each crevice in the bread, and fill with the onion mixture and the cheese. Wrap the entire loaf in foil, and bake on a baking sheet for 20 minutes. Then, remove the foil and bake 5 more minutes. Serve immediately.