How to undo  in Object Mode? Green color selection
Ctrl+G adds selected objects to a new Group

Objects belonging to a group show up in green.

Shift+Alt+G removes active objects from a group.

If more than one object is selected and when you press Shift+Alt+G but only one of them is removed from all groups, then afterwards press Ctrl+L > Groups to remove all selected objects from all groups.