An item such as a rock, which is not designated for any permissible function on Shabbat, has the Halachic status of "Muktzeh Machamat Gufo" and may not be moved on Shabbat. Moreover, if a rock or some other Muktzeh item was placed on another item, such as on a tray, or, in the case mentioned in the Gemara, a barrel, that tray or barrel is deemed a "Bassis" ("base") to the Muktzeh object, and therefore obtains the status of Muktzeh itself. This Halacha is, however, subject to a number of conditions, including that the Muktzeh item had been placed there intentionally. If one unintentionally left a rock on a barrel before Shabbat, the barrel does not become Muktzeh and it may be moved on Shabbat. (Shulhan Aruch, Siman 309)
The Beit Yosef (commentary to the Tur by Rabbi Yosef Karo, author of the Shulchan Aruch), in Siman 309, discusses an issue raised by the Terumat Ha'deshen (Rabbi Yisrael Isserlin, Germany, 1390-1460) concerning the status of a garment containing money in its pocket on Shabbat. If a person forgot to remove the money from the pocket before Shabbat, then certainly the garment does not become Muktzeh and it may be moved on Shabbat. The question arises concerning a case of one who intentionally left money in a pocket before Shabbat, as he did not plan to wear the garment on Shabbat, whether he may move that garment during Shabbat, or if it becomes a "Bassis" to the money.
The Beit Yosef distinguishes in this regard between different kinds of garments. If the pocket is part of the garment, (meaning fully attached) such as shirt pockets, then indeed the entire garment becomes a "Bassis" to the money and may not be moved on Shabbat. In cases, however, of a pocket that hangs from the garment, such as modern-day pants pockets, the pocket is seen as a separate entity from the rest of the garment. We would therefore not consider the pants a "Bassis" to the money situated in the pocket, and in such a case it would be permitted to move the pants on Shabbat.
It should be emphasized that this applies only when the money was intentionally left in the pocket before Shabbat. If one had intended to take the money out before Shabbat but forgot to do so, then regardless of the nature of the pocket the garment does not become Muktzeh and may be moved on Shabbat. (Menuhat Ahava, Helek 1, page 353-354.)
Summary: If money was accidentally left in the pocket of a garment before Shabbat, the garment may be moved on Shabbat. If the money was left there intentionally, then in the case of a shirt pocket, which is part of the shirt, the shirt may not be moved on Shabbat; pants pockets, however, are not considered part of the garment, and therefore one may move the pants on Shabbat even though it contains money in its pocket.