I hope that I shan't offend anyone by writing what I believe.
To my mind, Jesus Christ, who was a son of God (which we all are, because we are his children), spent an incarnation on Earth.
During that incarnation (which set him above others, in that he was born to a Virgin - a symbol of his purity - was still born as a human. Without doubt, a human who knew what his 'path' was to be; by that, I mean that he was aware of what he needed to accomplish in his life, but quite possibly did not know the details.
As we humans have, Jesus Christ had a soul from which he could not 'access' memories prior to his birth.
Therefore, it is my belief that he did not know the details of his death; only the purpose for which he was here, on Earth - just as some of us believe we know our purpose. I guess, when it came to the time, the realisation of what God expected of him was so staggering that he urttered those words.