Martouf was from an AU timeline where he was killed and, upon his death, ended up in Milliways. Somehow, he managed to leave Milliways (or he was removed) and was looped back through time to the period of Jolinar's Memories / The Devil You Know in order to 'correct' the original timeline so that it would match what we know as 'canon'. In the original timeline, SG-1, Selmac/Jacob and Martouf were all killed by Sokar because of a miscalculation / misinterpretation, so Martouf was sent back with just enough information to fix the 'goof' and keep them all from dying, hence the version we see in canon.
When he returns to Milliways in his current timeline, he won't remember having been to Milliways before, no matter what anyone tells him, because it won't have happened for him in this new version of the timeline.
This was what I came up with that would avoid negating all of his interactions in Milliways previously, but allow Martouf to be alive, and thus not a grumpy grump in my head.