During the war George Custer became a Major General of the volunteers, then reverted back to his permanent rank of Captain (a loss of five ranks) after the war. How were officers selected for promotion within both the confederate and union forces? Was it more based on battlefield promotions due to deaths and injury?
I wrote about this exact thing in this thread. Hopefully it answers your questions.
But in general it came down to deaths above them, seniority, if they had any patronage, and connections with state governments or Washington.