Tony Stark knew about Gamora. Remember the scene in Avengers: Infinity War where Nebula told others that Thanos went to Vormir with Gamora but came back without her. Then Quill who realized Thanos has killed Gamora got angered and attacked Thanos after Tony had told him to stay calm.
Why did Stark tell Quill to stay calm? Because he knew Quill was in a relationship (or at least in love) with Gamora (Quill was nervous about Gamora's fate prior to the incidents). A good guy is in a relationship (or is in love) with the step-daughter of a mad villain. So Stark had realized that Gamora, unlike her step-father, is a good guy. So he decided to not dust her away when he snapped.
Update: Another possibility is that Tony Stark didn't wish for wipingto wipe out Thanos and his army out when he snapped. But he wished for wipingto wipe out any villains who were in the area, which Gamora wasn't one of them.