Yang-Mills potential and principal bundles In section 2.7.2 of Bertlmann's "Anomalies in quantum field theory", it is stated that since a non-trivial principal bundle (based on a Lie group $G$) does not admit a global section, the Yang-Mills potential (the pullback of the connection on the total space) exists locally but not globally.
Covering the base space with various charts, we get different Yang-Mills potentials and we can identify two such potentials in the overlapping region of two charts, this give a transformation rule for going from one chart to the other chart. This is the geometrical interpretation of the gauge transformation.
Later, in section 6.1, the principal bundle of QED is defined based on $U(1)$, with the 4-dimensional Minkowski space being the base space. It is then stated that "the principle bundle is just trivial, $P=\mathbb{R}^4\times U(1)$, since the base space is contractible". 
From that, I infer that a single Yang-Mills potential can be defined globally on the base space and therefore there should not be any gauge transformation, which seems in contradiction with the usual textbook formulation of QED. What am I missing? Are things different for a non-Abelian Lie group?
 A: The term gauge transformation refers to two related notions in this context. Let $P$ be a principal $G$-bundle over a manifold $M$, and let $\cup_i U_i$ be a cover of $M$. A connection on $P$ is specified by a collection of $\mathfrak{g}=\mathrm{Lie}(G)$ valued 1-forms $\{A_i\}$ defined in each patch $\{U_i\}$, together with $G$-valued functions $g_{ij} : U_i \cap U_j \to G$ on each double overlap, such that overlapping gauge fields are related by
$$A_j = g_{ij} A_i g_{ij}^{-1} + g_{ij} \mathrm{d} g_{ij}^{-1}.\tag{1}$$
The transition functions must also satisfy the cocycle condition on triple overlaps, $g_{ij}g_{jk}g_{ki} =1$. This is the first notion of a gauge transformation, relating local gauge fields on overlapping charts.
Second, there is a notion of gauge equivalence on the space of connections. Two connections $\{ A_i, g_{ij} \}$ and $\{A_i',g_{ij}'\}$ are called gauge-equivalent if there exist $G$-valued functions $h_i : U_i \to G$ defined on each patch such that 
$$A_i' = h_i A_i h_i^{-1} + h_i \mathrm{d}h_i^{-1} ~~\text{and}~~ g_{ij}' = h_j g_{ij} h_i^{-1}\tag{2}$$
In terms of the globally defined connection 1-form $\omega$ on $P$, the local gauge fields $\{A_i\}$ are defined by choosing a collection of sections $\{\sigma_i\}$ on each patch of $M$. The local gauge fields are obtained by pulling back the global 1-form, $A_i = \sigma_i^* \omega$. On overlapping patches, such pullbacks are related by (1). On the other hand, the choice of sections was arbitrary; a different collection of sections $\{\sigma'_i\}$ related to the first by $\sigma'_i = \sigma_i h_i$ leads to the gauge-equivalence (2). 
Given a map $f: M \to M'$ between two manifolds and a bundle $P'$ over $M'$, we obtain a bundle over $M$ by pullback, $f^* P'$. Moreover, the pullback bundle depends only on the homotopy class of $f$. Suppose we have a contractible manifold $X$. By definition, there exists a homotopy between the identity map $\mathbf{1}:X \to X$ and the trivial map $p: X \to X$ which takes the entire manifold to a single point $p\in X$. Let $P$ be a bundle over $X$. The identity pullback of course defines the same bundle, $\mathbf{1}^* P = P$. On the other hand, the pullback $p^* P$ is a trivial bundle; it maps the same fiber above $p$ to every point on $X$. But the bundles $\mathbf{1}^*P$ and $p^*P$ are equivalent since $\mathbf{1}$ and $p$ are homotopic maps. Thus, a bundle over a contractible space is necessarily trivial (i.e. a direct product). 
In particular, a $G$-bundle over $\mathbb{R}^4$ is trivial, whether $G$ is abelian or non-abelian. The cover $\cup_i U_i$ has a single chart, $\mathbb{R}^4$ itself. There is a single gauge field $A$, which is a globally defined $\mathfrak{g}$-valued 1-form. It is obtained from the 1-form $\omega$ on $P$ by pullback, $A = \sigma^* \omega$, where $\sigma$ is a globally defined section. Picking another section $\sigma' = \sigma g(x)$ produces a gauge-equivalent connection, related to $A$ by the usual gauge transformation law given above. 
For more details, see e.g. Nakahara "Topology, Geometry, and Physics," chapter 10. 
A: There is something a little more subtle happening even in the case where spacetime is contractible $\mathbb{R}^4$. Even in this trivial setting, it is usually required (for physical reasons) that the connection one form decays at infinite radius. That is
$$A(x) \to 0\text{ as } |x|\to\infty.$$
As user81003's answer has already mentioned, we can only determine the connection 1-form up to gauge equivalence, so the condition that $A(x) \to 0$ is too strong. The best we can do is require that
$$A(x) \to h(x) d h(x)^{-1}\text{ as }|x|\to\infty.$$
for some choice of $G$-valued function $h(x)$ (which may only be defined for $|x|$ sufficiently large). 
There are two ways to interpret how this leads to topologically non-trivial bundles. The simpler (and more heuristic) way is to say that this decay condition means choosing the function $h(x) : S^3 \to G$ on the sphere at infinity. This "boundary condition" should only be defined up to continuous deformation, so we really only care about the homotopy class of $h$, which is an element of $\pi_3(G)$. 
An alternative view is to observe that the condition that $A(x)$ is gauge-equivalent to $0$ at infinity means that we may add the point $\infty$ to our spacetime manifold and the connection $A$ will still be well defined up to gauge. This means we should really look at principal $G$ bundles on the compactification of $\mathbb{R}^4$, which is $S^4$. Since $S^4$ is not contractible, it is no longer true that all principal $G$ bundles are trivial. As explained in user81003's answer, we now need to choose trivializing charts of $S^4$, which we can take to be the disks corresponding the the northern and southern hemispheres of the sphere (each extended a bit so they overlap). The intersection of these charts is the equator times a small interval $S^3\times (-\epsilon, \epsilon)$, which is homotopy equivalent to $S^3$. The transition function on this overlap 
$$g_{12} : U_1\cap U_2 \simeq S^3 \to G$$
then classifies the bundle. Again, this is only defined up to continuous deformation, so we see that the class of the principal $G$ bundle is determined by an element of $\pi_3(G)$. 
At this point, it is clear that the gauge group makes a difference as to whether there can be nontrivial bundles. For instance, since $U(1) \cong S^1$, we see that every map $S^3 \to S^1$ is homotopic to the constant map (in other words, $\pi_3(S^1) = 0$), so there are still no non-trivial $U(1)$ bundles on $\mathbb{R}^4$, even with the decay condition taken into account (as user81003 said, this does not mean there are no gauge transformations!). However, if $G = SU(2) \cong S^3$, then we see that $\pi_3(S^3) \cong \mathbb{Z}$ (the integer counts the degree of the map $S^3\to S^3$), so there are some nontrivial possibilities. This gives a topological interpretation for $SU(2)$ instantons on $\mathbb{R}^4$. There is a very brief discussion of this at https://en.wikipedia.org/wiki/Instanton#Quantum_field_theory but perhaps others know of better references.  
