During the
American Civil War, he enlisted in the state's Emergency Volunteer
Militia as a private in
Landis' Philadelphia Battery at the time of the
Robert E. Lee's 1863
invasion of Pennsylvania. After the
Confederates were defeated in the
Battle of Gettysburg, Gilder and his unit were mustered out in August. The death of his father, while serving as chaplain of the Fortieth New York Volunteers, obliged him to give up the study of the law.