A good way to remove tree sap from your windshield is to use some rubbing alcohol.
First use a windshield cleaning agent like Windex or even some vinegar and water and then wash or clean the windshield around the tree sap.
Then dip a rag into the rubbing alcohol or spray some rubbing alcohol onto the tree sap and then use the rag to wipe the tree sap away.
The rubbing alcohol should help to dissolve the tree sap and remove it.
You could also use some acetone based nail polish remover to clean the tree sap off your windshield.
To keep tree sap off your windshield you could place a tarp over the windshield when parked under a tree.
That is what I do when I park under a tree and want to prevent tree sap on my windshield I will put a tarp over the windshield.