The story of Shadgarbhas is mentioned in the Vishnu Parva of Harivamsha. They were the six sons of demon Kalanemi. They performed intense austerities and pleased Brahma who gave them the boon that they will not be killed by living beings, through curse, by demigods, or by divine beings.
Hiranyakashipu who was against the gods were not pleased Shadgarbhas propitiating Brahma who was born from the navel of Vishnu.
He cursed the Shadgarbhas that their father Kalanemi will kill them all.
Shadgarbhas then took refuge underwater and stayed there to be born on earth.
Eons later, Kalanemi was born as Kamsa.
Kamsa decided to kill the children of Devaki.
Vishnu used this as an opportunity to give moksha to Shadgarbhas.
He went underwater, took away the breath of life from Shadgarbhas, and handed it over to Goddess Nidra.
She implanted them in progressive order in the womb of Devaki.
All the six Shadgarbhas were killed on birth by Kamsa. They then attained Moksha.