When merging two records together, it will keep both sets of group memberships on the master record. It will add the master record to any groups that the losing record was in that the master wasn't already in. For example, if the losing record was in group 'ABC' but the master was not, after the merge the master record will now be in group 'ABC'.