As soon as you notice the stain, you should soak it in a tub of cold water. Allow it to soak for several minutes, and then fold the stain in on itself and rub the fabric vigorously. If the stain doesn't come out, let it soak for longer in the cold water and rub again to try to remove it. Once the stain is mostly out, run it through the wash, but never use hot water, which may make the stain permanent.
Lemon juice is very acidic. The acid in the lemon reacts with dirt on your laundry and helps lift stains from the clothes. If a dirt stain is not quite gone from your shirt when you put it in the laundry, run the machine as normal until it gets to the rinse cycle. Interrupt the cycle and add a half cup of lemon juice to the water, which helps get the stubborn dirt off the clothing.
Ammonia helps to get dirt stains out of anything when the stain has been stubbornly ground in. First treat the stain gently with a teaspoon of detergent diluted into a cup of water. Make a mixture of a tablespoon of ammonia with only a half cup of water, and blot the stain. Treat it again with the detergent mixture, then wipe it clean with straight water.
If you are dealing with white clothing, bleach may be the best way to get out ground-in dirt stains. Dirt is most visible on a white article of clothing, so keeping bleach around to correct this problem is important. Read the label of your clothing before you wash it with bleach in the machine as even some white clothing will have label warnings indicating that bleach should not be used.