Answer by taking a quote from the following article:

George Armstrong Custer (December 5, 1839 - June 25, 1876) was a United States Army officer and cavalry commander in the American Civil War and the American Indian Wars. Raised in Michigan and Ohio, Custer was admitted to West Point in 1857, where he graduated last in his class in 1861. With the outbreak of the Civil War, Custer was called to serve with the Union Army. Custer developed a strong reputation during the Civil War.

On June 30, 1863, Custer and the First and Seventh Michigan Cavalry had just passed through Hanover, Pennsylvania, while the Fifth and Sixth Michigan Cavalry followed about seven miles behind. Hearing gunfire, he turned and started to the sound of the guns. A courier reported that Farnsworth's Brigade had been attacked by rebel cavalry from side streets in the town. Reassembling his command, he received orders from Kilpatrick to engage the enemy northeast of town near the railway station. Custer deployed his troops and began to advance. After a brief firefight, the rebels withdrew to the northeast. This seemed odd, since it was supposed that Lee and his army were somewhere to the west. Though seemingly of little consequence, this skirmish further delayed Stuart from joining Lee. Further, as Captain James H. Kidd, commander of F troop, Sixth Michigan Cavalry, later wrote: "Under [Custer's] skillful hand the four regiments were soon welded into a cohesive unit...." Next morning, July 1, 1863, they passed through Abbottstown, Pennsylvania, still searching for Stuart's cavalry. Late in the morning they heard sounds of gunfire from the direction of Gettysburg. At Heidlersburg, Pennsylvania, that night they learned that General John Buford's cavalry had found Lee's army at Gettysburg. The next morning, July 2, 1863, orders came to hurry north to disrupt General Richard S. Ewell's communications and relieve the pressure on the union forces. By mid afternoon, as they approached Hunterstown, Pennsylvania, they encountered Stuart's cavalry. Custer rode alone ahead to investigate and found that the rebels were unaware of the arrival of his troops. Returning to his men, he carefully positioned them along both sides of the road where they would be hidden from the rebels. Further along the road, behind a low rise, he positioned the First and Fifth Michigan Cavalry and his artillery, under the command of Lieutenant Alexander Cummings McWhorter Pennington, Jr. To bait his trap, he gathered A Troop, Sixth Michigan Cavalry, called out, "Come on boys, I'll lead you this time!" and galloped directly at the unsuspecting rebels. As he had expected, the rebels, "more than two hundred horsemen, came racing down the country road" after Custer and his men. He lost half of his men in the deadly rebel fire and his horse went down, leaving him on foot. He was rescued by Private Norvell Francis Churchill of the 1st Michigan Cavalry, who galloped up, shot Custer's nearest assailant, and pulled Custer up behind him. Custer and his remaining men reached safety, while the pursuing rebels were cut down by slashing rifle fire, then canister from six canons. The rebels broke off their attack, and both sides withdrew. After spending most of the night in the saddle, Custer's brigade arrived at Two Taverns, Pennsylvania roughly five miles southeast of Gettysburg around 3 A. M. July 3, 1863. There he was joined by Farnsworth's brigade. By daybreak they received orders to protect Meade's flanks. He was about to experience perhaps his finest hours during the war. CANNOTANSWER

in what year was he in Hanover?

1863,