I would like to glue two pieces of pine together (at a right angle to eachother, flat sides together) using wood glue and nails. What do I need to do to prepare the wood?
All you need to do to prepare wood for glueing is to 'clean' the surface. This can actually just be cleaning in the literal sense of the word since a wipe down with soapy water (followed by rinsing with clean water), or using one of a number of solvents, is sufficient in some instances.
But generally it's better practice to expose new wood. For wood already at its final dimensions a very light scraping or sanding is normal.
If you're going to use sanding just a few passes with med-fine paper (240-320 grit) would normally be sufficient, just enough skim off the surface.
This is why wood should be worked freshly prior to glueing:
Source: Wood as an Engineering Material, 10-4, a Forest Products Laboratory publication.
In case it needs to be specified, clamp firmly. Good clamp pressure is what ensures a good bond, everything else being equal. Expect to have excess glue squeeze out of the joint, this is normal and indicates sufficient glue was applied initially.
From the comments:
I wasn't sure if I should use nails or screws.
On wood as thin as this a glue-only joint will almost always be good enough. The glue bond should be strong enough that an attempt to pull the pieces apart will result in one or both splintering along the grain.
I have to deal with end grain and side, but end is the smaller surface area and glue doesn't do well with ends according to brief research from earlier.
End grain doesn't bond as well as we'd like, but what is particularly weak is end grain/end grain joints. End grain to face grain can be much stronger than supposed and many sources have it wrong about how strong this can actually be in practice (as real-world tests demonstrate). If the end grain is sized prior to the final glue application it can glue much better, see Gluing end-grain .
The best glue joins, with wood, will have mated face grain surfaces i.e. no gaps between the wood where the glue is going. Generally smooth (sanded or scraped) wood surfaces are encouraged. Once the glue is place and covering both surfaces apply pressure, with clamps where possible. You should be able to put a fair amount so that you can see some glue seep out. Clean the glue that seeps with a rag.
Leave it together for at least as long and the glue needs to set. Longer if at all possible.
What you are describing is a lap join (Thanks AstPace!). Since you are going to be gluing face to face grain the glue should hold very well. Nails might not really be required unless you want them for aesthetic reasons. Since you are going to be close to the edge I would suggest you make some small pilot holes; not too small so the nails still exert pressure. This should discourage splits.
Depending on what this is going to be used for screws would be stronger. Pilots holes are still suggested.
Make sure the wood is clean (no paint/stain/staples) where you're gluing. Make sure the two boards are flat and square, when pressed against each other they should feel solid not wobbly.
Now just glue, screw or clamp if necessary and you're done.