If you’re like most knitters, the gauge is the bane of your existence. It's annoying, at best, to waste time and yarn on a little square. Yet without it you are playing yarn-ball roulette and risking the resulting sweater will come out too little or too large. So let’s take a minute to unravel (sorry couldn't resist) the mystery of the almighty gauge.
At its most basic, it refers to the number of stitches or rows it takes to go an inch. It sounds simple enough but the first key to finding a reliable gauge is to work a 4" by 4" square. By working over 4”any partial stitches will be forced to come out of hiding. If you think your gauge is 4 stitches per inch but over a larger test square it is actually 4.25 stitches to the inch, then we need to address it or your garment will come out too large. All those quarter stitches add up and quickly! For your horizontal gauge, if you have too many stitches per inch then increase your needle size. If you have too few stitches per inch then decrease your needle size. There are different styles of gauge tools but one of the most common is shown here. In this case you'll place it over the swatch and line up the window with both the vertical and horizontal rows. ( Using the ruler by the window edge count out the number of stitches per inch) Count it out over 4 inches then divide by 4 to get the gauge.
Most of the time, you will likely concern yourself only with the horizontal count. However, if you are knitting from a chart of a carefully choreographed pattern then the vertical gauge will be important. If the horizontal gauge is correct but the vertical is too short, use a larger needle on the knit rows only. Likewise, if the vertical gauge is too long use a smaller needle for the knit rows only. Yes, you read that correctly. Sometimes you knit with two different sized needles.
The second main point in knitting your test square is that you must knit it in the same pattern the garment will be knit in. Generally this will be stockinet but there are many times your swatch will be a lace pattern or ribbing (which you will stretch slightly when measuring) or cables. If the pattern is really complicated and the gauge changes across the row due to cabling, the pattern will sometimes direct you to knit the swatch in stockinet. If the right side is too complicated to clearly read the stitches, try turning the swatch over and measure the other side.
The picture below shows the proper placement of the gauge tool if you are knitting garder stitch.