Suppose $M$ is a smooth manifold and $P$ is a principal bundle on $M$. Let $U^\prime\Subset U\Subset M$ be strictly contained precompact open subsets. Let $g\in C^\infty(U, \hbox{Ad}P|\_U)$ be a gauge transformation of $P$ on $U$, is it always possible to extend $g|\_{U^\prime}$ to be a global gauge transformation, whatever it looks like? 


I guess it is true (at least in some cases, for example compact structure group) and tried to construct an extension via the adjoint bundle $\mathfrak{g} \_P=\hbox{ad}P$ (since extensions are usually dealt with vector bundles) and exponential map, but I just could not figure it out.


Also, if in general this is not true, is it true under some conditions, for example for some particular structure groups, e.g. $U(n)$ bundles, or with some topological constraints on $M$?


This question comes when I am reading Donaldson-Kronheimer’s book *The geometry of Four-Manifolds*, Chapter 4, Lemma 4.4.6.



Extend a gauge transformation
This is not always possible, even if the structure group is compact.


Let $M = \mathbb{R}^4, U' = \{x\mid \|x\|\in (2,3)\}, U = \{x\mid \|x\|\in (1,4)\}$, let $P = M\times SU(2)$ be the trivial $SU(2)$-bundle, and let $g: x\mapsto \frac{x}{\|x\|}$, using the diffeomorphism $S^3\cong SU(2)$. This fulfills all of your assumptions. An extension of $G$ to $\mathbb{R}^4$ would provide a retraction of $\mathbb{R}^4$ onto $S^3$, which is impossible since there is no such retraction on the third (co)homology groups.


In general, you are asking if the section $g$ of the fibration $P\times\_{ad} G\to M$ extends from $U'$ to $M$. If you only ask for an extension up to homotopy, that is a section $g'$ of $\mathrm{Ad}(P)$ such that $g'|\_{U'}\simeq g$, you can proceed by [obstruction theory](https://en.wikipedia.org/wiki/Obstruction_theory): There is a sequence of obstructions with values in $H^{n+1}(M,U';\pi\_n(G))$ such that the section extends up to homotopy iff all obstructions vanish. Note, however, that the extension is not unique, and that the higher obstructions are defined in terms of many previous choices and thus not very canonical.


