In addition to what is explained in @RiccardoDeContardi's answer, notice that, as it's explained by Federica Colombo in her book Grammatica e pratica della lingua italiana per studenti stranieri
indirect object pronouns gli and le + direct object pronouns lo, la, li, le and the pronominal particle ne become respectively glielo, gliela, glieli, gliele and gliene.
This book also explains that
With a verb at infinitive, gerund or imperative (but not the imperative of the courtesy forms) these and other combinations of two pronouns follow the verb and are written attached to it. For instance,
- Ricordati di dargliele!
- Trovandomelo davanti, l'ho dovuto salutare.
- Portatecelo qui!
- Dammelo!
You should also know that
With modal verbs, these combinations of pronouns can have two possible positions: they may precede the conjugated modal verb or they may be written attached at the end of the infinitive. For instance, you may both write
- Glielo devi restituire.
- Devi restituirglielo.
(Quoted texts are free translations of the information contained in the above mentioned book.)