The incident happened outside the Black Bull pub on Lockerbie's Station Road at about 22:25 on Saturday.
A 26-year-old man who was in the beer garden was approached by two men and an "altercation" ensued.
The victim was knocked to the ground by one of the men and the pair then made their way from the scene towards the High Street.
The man had been knocked unconscious and was taken to Dumfries Infirmary for treatment to cuts to his face.
PC Mike Briody said: "This was a nasty assault and could have resulted in the victim being very seriously injured as he was unconscious after the attack.
"As it was he required hospital treatment and received stitches as a result."
The men police are trying to trace have been described as:
Police said CCTV had shown a number of people in the area at the time and asked them to come forward.

An Ontario judge dismissed mischief charges against Anita Krajnc, ending a legal battle that captured the global attention of animal rights activists.
Judge David Harris said he was not convinced that Ms Krajnc obstructed the use of property when she gave water to pigs headed to slaughter.
Ms Krajnc said it confirms "compassion is not a crime".
Mischief to property is a criminal offence in Canada related to the wilful destruction or damage of property.
Justice Harris wrote in his decision that he is satisfied that Ms Krajnc "did not obstruct, interrupt or interfere with the lawful use, enjoyment or operation of any property" when in July 2015, she gave water to a few animals being carried in a tractor trailer filled with 190 pigs going to a slaughterhouse outside Toronto.
Ms Krajnc, who co-founded an organisation called Toronto Pig Save in 2011, regularly gathered with other activists on a traffic island at an intersection near a large slaughterhouse to pet the animals and give them water.
But this time, the truck driver confronted Ms Krajnc and police were called. A video of the tense encounter was posted online by the activists.
During her trial, supporters crammed into the courtroom, many sitting on the floor. Members of the media sat in the prisoner's box.
Despite her win on Thursday, Ms Krajnc told the BBC she has "mixed feelings" about the decision.
"We were hoping for recognition in the legal system that pigs and other animals are simply not property - that they are sentient beings, that they have basic rights," she said.
In his decision, Justice Harris noted that under Canadian law, pigs are property.
"Ms Krajnc and like-minded individuals may believe otherwise and they are fully entitled to that belief. That does not however make it so," he wrote.
Ms Krajnc's case and her efforts to "hold vigil" for animals headed to slaughter have caught on with animal rights activists around the world.
A number of similar "Save" campaigns have cropped up globally, including dozens in the UK. The movement promotes veganism, animal rights activism, and "bearing witness" to the suffering of animals.
Jenny Canham helped create the Essex Pig save chapter and told the BBC she was "really relieved" by Thursday's court decision.
She said her group will continue to advocate for animal welfare and to spread the movement in the UK.
Ms Krajnc said she will continue to organise "vigils" near slaughterhouses.

The airport said it represented a growth of 7.5% year-on-year.
The rise in passengers is connected to increasing capacity and frequency on existing routes, as well as new long haul services starting.
Ken O'Toole, the airport's managing director, called it a "magnificent achievement".
He said: "It's a historic milestone for Manchester Airport and UK aviation, as well as a huge boost for the economy and the north of England."
The figure beats the previous 12-month record set in July 2006 of 22.26m.
A man was left in hospital after being knocked unconscious in a south of Scotland beer garden.
[NEXT_CONCEPT]
A Canadian activist who faced time behind bars for giving water to pigs has been found not guilty.
[NEXT_CONCEPT]
Manchester Airport has broken its all-time yearly passenger record, with more than 22.32m people flying from the site over the last 12 months.