David McMurtrie Gregg was born in 1833 to a politically well-connected family in Pennsylvania. His grandfather, Andrew Gregg was a U.S. Congressman and Senator from 1791 to 1813; his first cousin Andrew Curtin went on to become the Keystone State's governor during the Civil War. After attending a local private school, David Gregg received an appointment to the United States Military Academy, graduating in 1855 alongside William W. Averell, Alfred T. A. Torbert, and Alexander Webb. His antebellum assignments as a dragoon took him to the Indian frontier and California.
In January 1862, Gregg was made colonel of the 8th Pennsylvania Cavalry and capably lead the regiment through the Peninsula and Maryland campaigns before receiving a commission as brigadier general that November. He was given a division in early 1863 and led it during Stoneman's Raid during the Chancellorsville campaign. The rest of May was spent patrolling the Virginia countryside in search of the Gray Ghost, John S. Mosby.
The Gettysburg campaign brought a revitalized spirit to the Army of the Potomac's mounted troops, beginning with the Battle of Brandy Station. Gregg marched his division into the Confederate rear, and surprised J.E.B. Stuart in his headquarters on Fleetwood Hill. Gregg's own delays on the march to Brandy Station and his lengthy preparatory bombardment, however, allowed the Confederates to meet the Union threat. Nevertheless, the Yankee troopers fared well against their gray-clad counterparts. In the next weeks, Gregg's horsemen fought at Aldie and again at Middleburg as the two armies moved north. On July 3, Gregg's division was covering the direct path to the Union rear at Gettysburg when they were attacked by Stuart's Confederates. The Federals responded with a series of mounted charges that drove the Confederates from the field and secured the Union army's rear. After the battle, Gregg aggressively pursued the Lee's retreating army to the Potomac and beyond.
After an autumn and winter spent mostly in skirmishing with Mosby, Gregg commanded his division during the Overland Campaign in 1864 and led raids against Lee's supply lines outside of Petersburg until February 1865, when he abruptly resigned from the army.
After the war, Gregg he accepted Ulysses S. Grant's offer to serve as U. S. Consul to Prague and also wrote an account of his division during the Gettysburg. The majority of his time, however, was spent at home in Reading, Pennsylvania, where he died in 1916.