Sometimes police use tricks or lies to get around your constitutional rights such as saying things like "It smells funny in your car, if you're doing nothing wrong, you don't mind if we look inside, do you?" This is an obvious way to get you to say "No, go right ahead." DO NOT DO THAT! EVER!
Simply say to the police, "I'm doing nothing wrong and I do not consent to a search of my vehicle." If they persist, ask to call your lawyer immediately.
Of course, there's no perfect way to handle the situation. Even if you tell them they can't search, they are still likely to do so if they think you look suspicious and to the police most people look suspicious. So stay as calm as possible and say as llittle as possible. You don't have to answer any questions and you don't have to offer any information.
In some cases, an officer may mention marijuana just to see if you react. If you appear to be nervous, the officer's suspicions will escalate and a search will likely ensue.
Police usually think they can tell just by looking at you if you're a "pothead," so be extra careful if there's anything about your appearance (like long hair, beard, beads, pot symbols hanging from your rear view mirror, cocaine spoons hanging from your neck or your girlfriend's ears, etc.) which may draw their attention or confirm their suspicions.
The manner in which you dress and/or the kind of vehicle you drive is a personal choice, but police definitely look out for certain stereotypes. If you think you look like a "stoner" you probably do, so you may want to reconsider how you appear and reconsider what paraphenalia you keep in the car with you.
Finally, don't smoke marijuana in or near your car. Many people have been arrested for smoking marijuana in public places (which is a more serious offense and a crime in New York) such as in their car or van, when they really could have avoided being arrested if they had thought better of it.
So don't give the police probable cause to search and find contraband and you'll be a lot better off.