Like all answers on this site... Practice..
It's hard to barre in the beginning but after a while you will get a hang of it.

One advice I can give you is to practice something like playing an open chord and then an barre chord and back to an open chord and so on... And when playing make sure that all notes play cleanly. I suggest strumming the chords very slowly one string at a time and change chord only when you get it right. If some string does not ring. Remove your grip and start over from the top.

One common mistake is the angle of the wrist. Make sure you sit down when practicing or use a shorter strap.