Your question sounds rather like asking how to keep fish out of water......
What is your aim in hoping to do this? What type of garden do you have?
Are the ants causing some kind of problem?
Unless they are causing problems, like eating your plants, they may be beneficial in helping keep the garden clean of little nasties that will cause harm to your garden. If you really want to eliminate them, find their mound, pepper it heavily with sweetened cornbread and muffin mix, it is real cheap. They go for the sweet, but can't digest the corn meal and it kills them. If the mound or ants are real large, it may take a few applications. The most I have ever had to do is three on a really large mound of really big black ants that my neighbor couldn't get rid of. While she was on vacation and we were taking care of her plants, I got rid of all the mounds I could find for her as a surprise. She couldn't believe that they were all gone! Just apply as long as you see activity on the mound, disturb it if you have to. This will not eliminate ants from your yard or garden, as they are a part of nature and more will come, but it will help, just watch for their homes.
How to Control Ants in Your Garden
Is there an anthill near by? In Japan, they dig it up and move it... Or, you can check online how to 'kill' the 'hill'