After extensive reorganization during the winter of 1863–1864, Walker and the Army of the Potomac fought in the Overland Campaign through May and June 1864. The Battle of Cold Harbor in early June took a substantial toll on the ranks of the II Corps and Walker injured his knee during the battle. In the ensuing Richmond-Petersburg Campaign, Walker was appointed a brevet colonel. However, on August 25, 1864, as he rode to find Maj. Gen. John Gibbon at the front during the Second Battle of Ream's Station, Walker was surrounded and captured by the 11th Georgia Infantry. On August 27, Walker was able to escape from a marching prisoner column with another prisoner but was recaptured by the 51st North Carolina Infantry after trying to swim across the Appomattox River and nearly drowning. After being held as a prisoner in Petersburg, he was transferred to the infamous Libby Prison in Richmond, where his older brother was also held. In October 1864, Walker was released with thirty other prisoners as a part of an exchange.