Absolute labels for notes — collaborative tex writing git

The context is collaborative latex writing using GIT and some online repository. I have a simple macro that uses a counter to index notes in a pdf, which puts a number in the margin:

\documentclass[11pt]{article}
\usepackage[dvipsnames]{xcolor}

\newcounter{mynote}
\newcommand{\note}[1]{% a simple margin note
\refstepcounter{mynote}% step counter
{\color{red} ToNote;~#1
\marginnote{\color{red}\mbox{\textbf{[\themynote]}}}}% the note
}

\begin{document}
Here is some text \note{with a note.}

\end{document}


The problem with this solution is that the labels will change (in general) each time a new note is added in the text. This makes it hard to discuss when several versions are pushed/merged, with text edits and new notes added.

I have no MWE for this as I am not sure how I should proceed: would writing some data in an auxiliary file be optimal ? Maybe there would be a way to use the hash of the last commit ? That would probably lead to rather random and annoying label names though.

• unrelated but you are missing a % after #1 (otherwise you get at least a word space and possibly a line break between the text and the node holding the marginpar) – David Carlisle Dec 13 '16 at 12:44

This is really no different to \section{hello} or any other automatically numbered thing.
The standard latex way would be to use \note{\label{abc}some text here} then you have the internal stable identifier label abc which you can refer to in discussion (or in the document as \ref{abc}) even if the text or number of the note changes.