First of all, it's not true that any group can be realized as the commutator subgroup of some group. So, if we assume that there is atleast one group H with H' isomorphic to G, how to construct all such groups H?
To start with, we may assume that G is finite. Can we classify all (finite) groups with commutator subgroup isomorphic to G?