Rory Gildea, 22 was walking home from a party in Ballybofey when he threw the bottle across a road.
Garda Kieran McDermott was driving home after completing his shift when the bottle struck the grill of his car, Letterkenny District Court was told.
He contacted his colleagues who quickly arrested Gildea, of Forest View, Ballybofey.
Solicitor for Gildea, Mr Kieran Dillon, said his client did not know Garda McDermott but was merely discarding the bottle which accidentally struck the passing car.
He said he had never had any dealings with the Garda and was very sorry for the incident.
Gildea appeared in court charged with criminal damage, intoxication and using threatening abusive or insulting behaviour.
Judge Paul Kelly said the incident could have had very serious consequences for Garda McDermott.
Inspector John O’Toole told the court that Gildea, whose partner is expecting a child, has previous convictions for burglary and criminal damage.
Judge Kelly adjourned the case until May 25th for a probation report.
He warned that he may not be in a position to give the accused community service.
“This man has been causing a lot of trouble and he could have caused an accident with very serious consequences,” he said.