Custer graduated last in his class and served at the First Battle of Bull Run as a staff officer for Major General George B. McClellan in the Army of the Potomac 's 1862 Peninsula Campaign . After the battle he was assigned to the 5th U.S. Cavalry , with which he served through the early days of the Peninsula Campaign in 1862 . As a staff officer for Major General George B. McClellan , Custer was promoted to the rank of captain .