The first source comes from around the 16th century when people bought pigs at the market. These pigs came in a bag and this lead to the expression pig in a poke (bag). Some unsavoury merchants would sometimes put a cat inside the bag instead of the whole pig, in order to trick unsuspecting buyers. This allowed the merchants to cut down on their costs.
|The cat o' nine tails|
If someone is about to reveal a secret and you use this phrase don’t forget about the dead cat in the bag or the crack of the whip.