A federal judge here dismissed an attempt by a public employes union yesterday to restore a tax break once enjoyed by goverment workers who contributed to their pensions.

U.S. District Judge Harold Greene threw out a suit by the American Federation of Government Employees challenging a provision of last year's tax-revision law that called for immediate taxation of federal pension benefits.

Under the old tax code, about 20 million federal, state and local government retirees who paid into their pension funds were not taxed on their benefits until they had recovered the amount of their own contribution.

As a result of that provision, retired federal employes did not have to pay taxes on pension checks for an average of 19 months.

The law, passed by Congress last August, is expected to cost the typical federal retiree $10,000 over the measure's first three years, and to raise a total of $7.5 billion in government revenue over that period.

Greene said the suit was barred by the Anti-Injunction Act that prohibits legal action to restrain the collection of taxes.

The union, which represents federal, state and local workers, contended the new provision was an unconstitutional denial of due process and property rights. The union argued that pension contributions already had been taxed as income at the time it was withheld from employes' paychecks.

There was no immediate comment from the union.

Greene rejected the union's argument that the lawsuit was not purely a tax case barred by law.

Greene suggested that affected taxpayers could file suits to obtain refunds as an alternative to seeking to stop the government from collecting the taxes in the first place.

The law has had little effect on the private sector, where employe contributions to pension funds are rare.