You should always put the Jira/story id in the merge commit at least.
If it's long term valuable, i.e. "I considered obvious, attractive alternative algorithm X but it failed horribly because of Y", I'd prefer that to go in a comment in the code instead. Far more likely to still be noticed in three years time, after the code's been run through two different auto-formatters and otherwise mangled around.
Especially for git, because old branches can be cleaned up/deleted which results in a loss of tracking.