Mayor Bill de Blasio barred officials from the NYPD and the CCRB from testifying Thursday about the planned repeal of a law that shields police personnel files — so they wouldn’t clash in public, The Post has learned.

NYPD Deputy Commissioner Benjamin Tucker and Civilian Complaint Review Board Chairman Fred Davie were scheduled to appear back-to-back before the state Senate Codes Committee in lower Manhattan, according to an official agenda for the public hearing.

But both men canceled their appearances on Hizzoner’s orders, according to a source familiar with the matter.

“Instead of letting both sides testify and having an honest conversation, they ordered both sides not to testify,” the source said.

“There’s been a debate inside City Hall [over the issue]. There’s been a push inside the Mayor’s Office for the mayor to push the NYPD to push for reform, further than they were comfortable with.”

The controversy stems from a proposal to repeal Section 50-a of the state Civil Rights Law, which blocks public access to all government records used to evaluate the performance of cops, firefighters and correction officers.

The law was enacted in 1977 in part to prevent defense lawyers from using the Freedom of Information Law to obtain unsubstantiated complaints of police wrongdoing, then cross-examine cops about those incidents on the witness stand.

Opposition to the law heated up when reporters and others were unable to get the CCRB records of NYPD cop Daniel Pantaleo following his deadly 2014 arrest of Eric Garner, for which Pantaleo was fired in August.

Garner’s mom, Gwen Carr, testified Thursday that the law has kept her from learning about “the misconduct or discipline histories of other officers involved in killing Eric and covering it up.”

In February, NYPD Commissioner James O’Neill said he favored putting cops’ disciplinary records online, but withholding information when “the facts are not fully known” or when it poses a “risk to ­officer safety.”

Davie has never taken a public position on Section 50-a.

City Hall didn’t return a request for comment.

Additional reporting by ­Julia Marsh