Jesus never sinned. The Catechism of the Catholic Church states,
Following the holy Fathers, we unanimously teach and confess one and the same Son, our Lord Jesus Christ: the same perfect in divinity and perfect in humanity, the same truly God and truly man, composed of rational soul and body; consubstantial with the Father as to his divinity and consubstantial with us as to his humanity; "like us in all things but sin." (CCC 467)
So how did he, in his humanity, keep from sinning? He submitted his will completely to the will of his Father.
Christ possesses two wills and two natural operations, divine and human. They are not opposed to each other, but cooperate in such a way that the Word made flesh willed humanly in obedience to his Father all that he had decided divinely with the Father and the Holy Spirit for our salvation. Christ’s human will does not resist or oppose but rather submits to his divine and almighty will. (CCC 475)