If the Confederate officers/soldiers left the U.S. Military for the Confederate States military, did they retain their previous ranks, or had to start from the beginning (2nd Lieutenant/Private)?
Though the previous rank was an important consideration, there was no automatic transfer of rank. This was almost irrelevant, as experienced officers were given promotions to higher ranks - the larger wartime army required more general officers, more colonels, etc., and so experienced officers were commissioned to serve at those higher ranks.
Joseph E. Johnston felt that his US Army rank was not given enough consideration in giving him a CS commission. As a brigadier general, he had been the highest ranking officer to join the Confederacy, but when promoted to full general he was ranked fourth behind Samuel Cooper, Albert Sidney Johnston, and Robert E. Lee - three men he had outranked in the US Army. This slight was one of the causes of his bad relationship with President Davis.
Incidentally, Lee wore a Confederate Army colonel's uniform throughout the war, representing his rank in the US Army.