  This is the first in a sequence of two articles investigating moduli stacks
of global G-shtukas, which are function field analogs for Shimura varieties.
Here G is a flat affine group scheme of finite type over a smooth projective
curve, and global G-shtukas are generalizations of Drinfeld shtukas and analogs
of abelian varieties with additional structure. Our moduli stacks generalize
various moduli spaces used by different authors to prove instances of the
Langlands program over function fields.
  In the present article we explain the relation between global G-shtukas and
local P-shtukas, which are the function field analogs of p-divisible groups
with additional structure. We prove the analog of a theorem of Serre and Tate
stating the equivalence between the deformations of a global G-shtuka and its
associated local P-shtukas. We also investigate local P-shtukas alone and
explain their relation with Galois representations through their Tate modules.
And if P is a smooth affine group scheme with connected reductive generic fiber
we prove the existence of Rapoport--Zink spaces for bounded local P-shtukas as
formal schemes locally formally of finite type. In the sequel to this article
we use these Rapoport--Zink spaces to uniformize the moduli stacks of global
G-shtukas.
