Out numbered 6 to 1, the prison group has no chance to win. They can hurt the Woodbury forces, but they can't win.
The best way to win would be to not fight there at all. Put Walkers in the prison where they were living and leave. Place Beth and the baby stay in the freight train near Woodbury but far enough away that you wont hear the baby cry. The rest of the team wait close enough so that when The Governors forces leave the team can seize Woodbury. Lay traps, explosives, and everything else. Then leave as the group comes back to a more defensible position.
As the explosive explode, Rick's team has the advantage of picking targets and eliminating only the paramilitary tropes and leave the conscripts alone. Killing as few conscripts as possible, they are already sheep, they will stay sheep under new control -their not the threat The Governor is.
Beside a wholesale departure, that is the best plan. Defending the prison just isn't wise as it has a number of problems.