He is like Hunt’s dog, will neither go to church nor stay at home. One Hunt, a labouring man at a small town in Shropshire, kept a mastiff, who on being shut up on Sundays, whilst his master went to church, howled so terribly as to disturb the whole village; wherefore his master resolved to take him to church with him: but when he came to the church door, the dog having perhaps formerly been whipped out by the sexton, refused to enter; whereupon Hunt exclaimed loudly against his dog’s obstinacy, who would neither go to church nor stay at home. This shortly became a bye-word for discontented and whimsical persons.
Definition taken from The 1811 Dictionary of the Vulgar Tongue, originally by Francis Grose.
Hunks * HuntingNathan Bailey's 1736 Dictionary of canting and thieving slang
John S. Farmer's collection of canting songs and slang rhymes