Conventional wisdom says you should only glue wood side to side, not end to end. That said, you can indeed glue end grain and it’s not guaranteed to be a disaster. Here’s why you might want to glue end to end, and how.
Gluing end grain
Glue works by soaking into the wood and hardening to hold it together, similarly to how lignin works. Lignin is the naturally occurring substance that holds wood grains together.
The wood fibers are like straws, so they readily absorb glue. The key when gluing end to end is to use lots of glue, since more will get absorbed than when you glue side to side.
The other tricky part is holding the joint together, since you’re probably gluing to get a longer piece, and you probably won’t have a clamp long enough to hold the boards together. If you do, use a clamp. If you don’t, you will have to improvise. If you can balance the pieces together, the weight should suffice to hold the joint tight until the glue dries. The last time I had to do this, what I did was apply a generous amount of glue to both sides, let it sit a few minutes to get tacky, then press the two pieces together.
Also, when you do this, you want squeeze out. If no glue squeezes out, you didn’t get enough glue, and you will have a weak joint. Make sure you apply enough glue to have squeeze out.
But that’s the only special trick. It’s not as tricky as gluing cracked wood.
Why they say not to do this
The conventional reason for not gluing this way is that when you stress the board, it will always break on the glued joint. When you glue side to side and stress the joint, it never breaks on the glue joint. It may break near the joint, but the break is always somewhere else.
The reason for this is because glue is stronger than lignin. How much stronger depends on the species, but it’s generally about twice as strong.
The wood fibers, however, are about three times stronger than the glue. That’s why the glue always fails when you break a board glued up end to end from two boards.
But that’s not to say. It’s just not as strong. For some uses, especially if the board isn’t going to take side to side stress, it’s fine. So if you run short on lumber and need to glue up some boards to get enough length, this is one way to make some scraps and off cuts usable. They won’t look great, but if you use them in a place they aren’t visible, and they aren’t having to provide all of the structural strength, they can be fine.