Step 1. Sometimes 1 measurement is worth 1,000 guesses. Measure the width of your bottom bracket shell (Probably 73mm). Measure the distance between your rear dropouts (Probably 135mm).
Step 2. Pick out the crank that you want. New cranks will generally recommend a bottom bracket spindle length. XT octalink cranks, for example, suggest 113/118 spindle.
Step 3. Pick a bottom bracket that matches both your bike's frame and your new crank. There are three things to consider:
a. Spindle interface: Has to match your crank. There are actually 2 different octalinks. For an XT crank you want the V2.
b. BB shell width: Has to match your bike. Go to step 1.
c. BB spindle length: Has to match both. Combine step 1&2. With 135mm dropouts you'll want the longer 118mm spindle length to get the chain line right.