  We analyze the interplay between charge-density-wave (CDW) orders with axial
momenta $(Q, 0)$ and $(0,Q)$ ($\Delta_x$ and $\Delta_y$ respectively), detected
in the underdoped cuprates. The CDW order in real space can be uni-directional
(either $\Delta_x$ or $\Delta_y$ is non-zero) or bi-directional (both
$\Delta_x$ and $\Delta_y$ are non-zero). To understand which of the two orders
develop, we adopt the magnetic scenario, in which the CDW order appears due to
spin-fluctuation exchange, and derive the Ginzburg-Landau action to the sixth
order in $\Delta_x$ and $\Delta_y$. We argue that, at the mean-field level, the
CDW order is bi-directional at the onset, with equal amplitudes of $\Delta_x$
and $\Delta_y$, but changes to uni-directional inside the CDW phase. This
implies that, at a given temperature, CDW order is uni-directional at smaller
dopings, but becomes bi-directional at larger dopings. This is consistent with
recent x-ray data on YBCO, which detected tendency towards bi-directional order
at larger dopings. We discuss the role of discrete symmetry breaking at a
higher temperature for the interplay between bi-directional and uni-directional
CDW orders and also discuss the role of pair-density-wave (PDW) order, which
may appear along with CDW. We argue that PDW with the same momentum as CDW
changes the structure of the bi-directional charge order by completely
replacing either $\Delta_x$ or $\Delta_y$ CDW components by PDW. However, if an
"Amperean" PDW order, which pairs fermions with approximately the same momenta,
is also present, both $\Delta_x$ and $\Delta_y$ remain non-zero in the
bi-directional phase, albeit with non-equal amplitudes. This is again
consistent with x-ray experiments, which at larger doping found non-equal
$\Delta_x$ and $\Delta_y$ in every domain.
