The story of Cash, the missing Australian shepherd, has an unusually happy ending.

Owner Dave Scheller on Monday said Cash was returned to him and girlfriend, Renee Clopton, over the weekend by a Livermore resident who had adopted him weeks ago.

How Cash got to Livermore, by way of a Fremont animal pound, is a mystery that may never be solved.

But his safe return ends an epic dog hunt, dating to early January, that involved dozens of newspaper ads, a Facebook page, thousands of posters plastered across a five-county area, and knocking on hundreds of doors.

Cash’s disappearance was discovered Jan. 4. Clopton returned to her Fraguero Road home to find him and their other dog, a Chihuahua, were missing.

Neighbors saw Cash running near Highway 49 that evening. Witnesses saw the driver of a pickup truck stop to get him off the road, and the dog wasn’t seen again.

A few weeks ago, Dave Bergersen adopted a surprisingly friendly Australian shepherd from the animal shelter in Fremont. The dog, named “Banjo” by pound staffers, was found roaming around the South Bay town.

Bergersen, who owns another shepherd and a border collie, said he was struck by two things — his rare markings held by a type of shepherd known as merle Aussies and his friendliness.

Bergersen Sunday took his new pet to Copperopolis for a playdate with another dog owner. At a mini-mart, he saw one of the Cash posters.

He called Scheller and Clopton.

“We went down there and, sure enough, it was him,” Dave Scheller said. “I was just in shock. I couldn’t comprehend everything.”

“We could never figure out why no owner would come and look for him,” Bergersen said. “Within two days, he was my shadow.”

Parting with Cash was hard, Bergersen said. He explained he gave up an adopted merle earlier when the previous owner asked for it back, and then he lost a second when it escaped from home.

“It was hard for five minutes knowing I had to give him back, but you’ve got to do the right thing,” he said. “If I hadn’t walked into that gas station, I would have never noticed.”

Scheller still wonders how Cash got to Fremont in the first place.

“I’m going to dig into that a little closer,” he said. “We would never have (expanded the search) that far. He didn’t just walk to Fremont.”