Fortunately, forming a long-lasting alliance with Gilgamesh is quite easy, since that's one of his main agendas. I've never had a game in which I wasn't able to renew my alliance with Gilgamesh each and every time it expired (every thirty turns). I would recommend starting a game (with Gilgamesh as an opponent of course), on a smaller map in an earlier age so you can find him quickly and establish a good relationship early on.
On the turn you meet Gilgamesh you can become friends. I believe his is the only civilization where this is possible. Then, as soon as you can establish an alliance, do so, and you'll start accumulating alliance points. Alliances are unlocked with the Civil Service civic. Finally, play a relatively friendly game, so you don't cause too many grievances with others, just in case it might upset Gilgamesh.
Here are some things that will increase your alliance points gained each turn:
+1: Maintaining an alliance
+0.25: Having a trade route to your ally
+0.25: Having a trade route from your ally
+0.5: Being at war with the same enemy as your ally
+?: The Wisselbanken policy card will grow 25% faster with each ally (unlocks with the Diplomatic Service civic in the Renaissance era)
+?: There may be other policies or traits available - keep an eye out for them, but the above should be sufficient to get to level 3 within a normal game.
Keep up the alliance with Gilgamesh and make sure you don't transgress him and you should be good. You can check your alliance level with him on the diplomatic interaction screen. The alliance level information is under the flags icon.
Let me know if you have any other questions in the comments section.