Your bike will hate you a lot less if you do your shifting all in advance of the hill and never shift in either direction once on it. Something to bear in mind is you have a motor now so the need to row thru the gears to get just the right ratio while in a climb is a
lot less than on an analog bike. For example, with motor assist now vs. days of yore I can just change my effort level (more effort or less effort) and maintain cadence for a short stretch thanks to a changed assist level. That is just not possible on a purely human-powered bike. If the hill steepens I would have to downshift a bike. But on an ebike I can go from '3' to '4' and change nothing else. And if it levels off a tad maybe I drop back to '2'.
@Catalyzt and a couple of others mentioned overdoing it initially. Shift to a lower gear than you think you will need. I do this as well. When I said to fuggeddaboud speed this is what I was doing a poor job of articulating: Let the speed drop waaaay down by going into a too-high gear. You end up going slowly but easily (so much so you may need to back way off on the assist level). Go up the same hill a couple three times and you'll know in advance where you want your gear to be, but during your initial uncertainty phase you will err on the safe side. Erring on the other side and being in a too-high gear is a lot messier. What you want is a gear that is mechanically able to easily handle the hill, so all you have to do from there is click PAS levels up or down.
As others have mentioned there are ways to further fudge this, like with a momentary burst of effort to gain enough speed you can lift your pedal effort and shift before you run out of momentum. The easy, just-learning way is to shift at the bottom just before the hill. Get fancy later.
Yeah this is a tool that is the proverbial game changer.
What I found is that, since the hub motor is powering the bike thru the axle/hub and it couldn't care less about the drivetrain (and is in fact disconnected from it due to an internal clutch) you can shift to your heart's content with no restrictions of any kind. Do your worst. If anything the hub motor in the mix makes shifting less consequential to any sort of potential drivetrain stress.