Heat the olive oil in a medium pan set over medium heat. Add the onions and cook, stirring occasionally, until softened and lightly browned, 5 to 7 minutes. Add the garlic and spinach and cook, tossing with tongs, until the garlic is fragrant and the spinach wilts, about 2 minutes. Remove from the heat and set aside.