Let $M$ be a manifold. Two stackexchange posts state that there is a correspondence $$ \{ (P,A): P \text{ a $G$-bundle}, A \text{ flat connection} \} \leftrightarrow \{ \text{morphisms } f:\pi_1(M) \rightarrow G \}, $$ namely Recovering a principal connection from its monodromy and Are vector bundles given by their monodromy?.
I believe that the correspondence is given by $$ (P,A) \mapsto f, $$ where $f([\gamma])=g$, where $g$ denotes the element such that $\gamma^*(0)g=\gamma^*(1)$. Here $\gamma^*$ denotes a horizontal lift of $\gamma$. This is well defined by flatness of $A$.
If $\pi_1(M)$ is a free group, I understand why the correspondence is 1-to-1. That is because to define a $G$-bundle on $M$ I need to specify precisely an element in $G$ for each loop in $\pi_1(M)$, that is the idea mentioned in the accepted answer of the question https://mathoverflow.net/questions/4138/why-are-local-systems-on-a-complex-analytic-space-equivalent-to-vector-bundles-w?noredirect=1&lq=1.
Why is this correspondence 1-to-1 in general? Can you point me to a reference which contains the proof?