An internal thread--called a female thread--is the thread on the inside of a hole, that a bolt screws into. It is created with a tap. An external thread--such as the threaded end of a gas pipe--is called a male thread. It is created with a die. Taps are cylindrical pieces of metal with a thread on one end which fits into the pre-drilled hole. Dies look like a fat metal washer, with threads around the central hole. This fits over the end of a pipe and is twisted to create the pipe thread.
Drill the hole to the correct depth, using a metal drill bit. Use the same diameter drill bit as the diameter of tap--for example, if the hole is 1/2-inch diameter, use a 1/2-inch diameter tap. Clean away any shavings from around the hole.
Place cutting oil around the tap's thread. Then put the tip of the tap into the drilled hole, making sure the tap is 90 degrees to the hole.
Twist the tap clockwise 1/4-turn. Then twist it counter-clockwise a little, to remove any shavings. Twist it again clockwise another 1/4-turn, before twisting it counter-clockwise to remove more shavings. Continue in this fashion until the tap reaches the end of the drilled hole. Remove the tap by twisting it counter-clockwise, and wipe away any shavings/oil from the entrance of the hole.
Tighten the pipe in a metal vice. Brush cutting oil around the end of the pipe.
Fit the die over the pipe end at 90 degrees to the pipe, and slowly make a clockwise 1/2 turn.
Turn the die counter-clockwise 1/4 turn, to remove shavings. Then make another clockwise 1/2 turn, before turning it counter-clockwise 1/4 turn, as before. Continue in this fashion until the thread's length is a little short of the die's thickness--in other words, stop threading just before the newly-cut pipe thread starts to poke out at the end of the die. Turn the die counter-clockwise to remove it from the pipe.
Wipe any oil and shavings from the pipe thread, and remove the pipe from the vice.
Carefully wipe away the shaving with the rag, as the shavings will be sharp.