I've usually tended to finger all strings for both chords, so what I suggest is barre 3rd fret with index, and use ring and pinky on strings 5 and 4 for Gm. There's no need to actually play any more than the top four, though.
Then slide the barre up to fret 5, moving ring and pinky across to strings 4 and 3, leaving middle to drop onto the 2nd string.
The whole process is quite a common one, sometimes playing G major in place of Gm, which actually makes the three finger change all move together. For practice, try hammering all on each position in turn - the idea is all fingers arrive together, not in installments. But it's made easier with the gaps (rests) between changes.
And - chords are usually written 6th string > 1st, so XX5333, for example.