We present a scheme to generate the tripartite GHZ state via cavity quantum electrodynamics. Our scheme is based on the resonant interaction of a V-type three-level atom with the cavity fields for precalculated interaction time. Also, this scheme can be directly generalized to prepare the general n-qubit GHZ state.