Preventing enemy Ganks 
The most efficient way to avoid a gank is 
turtling, the act of
 farming away from enemy territory by preventing your creeps from 
pushing too far by last-hitting enemy creeps at the very right moment 
and denying your own. In the early game, it is difficult to perform a 
gank if a Hero is just beside a tower. Not only will the tower deal high
 damage, but other enemies can easily kill the ganker by using 
Town Portal Scrolls to reach the tower in time.
Items are useful in preventing the enemy team from ganking. A team should maintain vision of key areas of the map by placing 
Observer Wards and using 
Sentry Wards
 to reveal invisible Heroes. Furthermore, Town Portal Scrolls can be 
used to assist allies who are ganked on the other side of the map. 
Carrying TP Scrolls, maintaining vision, and watching the minimap allow a
 team to quickly gain a numbers advantage over the gankers and kill 
them.
A common way to protect your team from ganks is telling your 
teammate when an enemy leaves their lane. In public games, this is done 
in team chat. For example, calling out "miss 2 bot", "
ss 2 bot" or "
MIA 2 bot" lets your team know that two enemy Heroes have left the bottom lane and may be ganking.
Some abilities like 
 Mirana's 
Leap are well-suited to escaping from incoming ganks. These abilities are often referred to as 
escape mechanisms. Heroes lacking an escape mechanism like 
 Shadow Fiend and 
 Silencer
 are susceptible to ganks and must be especially careful when enemy 
Heroes are missing on the minimap. These Heroes can purchase items like 
Shadow Blade or 
Force Staff to gain an escape mechanism.
Other Heroes have abilities that help with map control through 
temporary vision, pseudo-wards, temporary summons, and illusions. 
 Clockwerk's 
 Rocket Flare, 
 Vengeful Spirit's 
Wave of Terror, and most of 
 Zeus's abilities are prime examples of abilities that reveal the map temporarily for an advantage. 
 Venomancer's 
Plague Ward is also a great anti-gank tool because the wards provide vision and can be spammed. The minions summoned by 
 Lycanthrope's 
Summon Wolves, 
 Enchantress' 
Enchant, and 
 Nature's Prophet's 
Nature's Call provide vision as well. 
 Night Stalker with an 
Aghanim's Scepter has protection against ganking – the Scepter gives him the ability to see through cliffs and trees at night. 
 Slardar's 
Amplify Damage, 
 Bounty Hunter's 
Track, and 
Necronomicon have some anti-gank utility.
Source:dota2.gamepedia.com/Ganking