Ditto is a very unique Pokemon in the games, as its entire strategy in combat is based off of cloning another Pokemon temporary for its moves and types. However it is because of this that Ditto cannot normally learn any other moves other than Transform, on the exception of cheats and hacks like Gameshark. There is a glitch though that will allow Ditto to keep the moves of a Pokemon it transforms into, losing Transform in the process. The ability to do this is only available in the fourth generation of games, so Diamond, Pearl, Platinum, Heart Gold, and SoulSilver. The ability to unlock this comes from an unlikely source: Rage
Rage has a unique mechanic in the games. Upon its subsequent use, every time the user is hit by an attack, its power increases, followed by a message which says “(Pokemon here)’s Rage is building”. In order to successfully use the glitch, the Pokemon’s move set which you are trying to copy must contain ‘Rage’, because your transformed Ditto will need to use it. Now to begin, initiate the combat with the Pokemon who has the desired move set, and Transform into it. You will receive all four of the Pokemon’s moves, including Rage. Proceed to attack using Rage over and over, until the attack runs out of power points. Once it does so, proceed to either defeat or capture the opposing Pokemon with a move other than Rage. Once the battle is over, Ditto will retain the move set it copied, though in the process will lose Transform. During this process though, you need to make sure that Ditto does not faint, or get switched out during the combat, or else the progress on it will be lost, and you’ll have to start from scratch. What increases the possibilities of this move is that through the use of any move-copying ability that can make use of Transform (such as Metrenome, Assist, Copycat, and Mimic), the method of using this glitch in their case becomes a little trickier, as the alternate methods can only be done in double battles, and the Pokemon who wants to learn the new move set must be the one to attack and defeat the opponent, without getting knocked out or switched out in the process, and without knocking them out with Rage.
As a final note, Ditto is one of the most versatile Pokemon in the game because of its breeding capability. On the exception of legendaries (except for Manaphy), Ditto can breed with any Pokemon that has an egg type, and can produce an egg as a result. The ability to have Ditto learn moves will therefore change the way that Pokemon are bred, as in theory it would be capable of passing down the new moves that it learns. This could be extremely useful for obtaining hard to learn abilities that a player would want past down to the next generation of bred Pokemon.