The consonant is doubled if there is a short vowel between consonants in a stressed syllable:
forgetting, swimming
If the syllable is not stressed, doubling doesn't occur:
targeting
No doubling occurs if the vowel is pronounced as a diphthong:
growing
In British English - illogically - l is doubled even in an unstressed syllable in similar words:
travelling
There are numerous cases where usage is unsettled and you have a choice:
focused / focussed
CB