Click and embiggen for great detail.
Geologic studies have shown that glaciers have moved through Yosemite Valley during a number of glacial episodes. Between 2.5 million to 200,000 years ago about 36 different glacial episodes have been identified in the Yosemite area. All of these episodes are combined into what is called the Pre-Tahoe glaciations. However, one episode, the Sherwin Glaciation is the most notable. It began between 900,000 and 800,000 years ago and lasted over 300,000 years. The valley was completely filled even extending a short way above the rim. The glacier extended as far as El Portal. However, Half Dome still stuck some 900 feet above the glacier. At that time the highest mountains were only about 9,500 feet above sea level.
It was during the Sherwin glaciation that the majority of the erosion of Yosemite Valley is thought to have taken place. As the glaciers from the Tenaya and Merced Glaciers combined the thickness and velocity of the merged glacier gouged out a deep basin in the area of the Ahwahnee Hotel and Camp Curry. This basin is about 2,000 feet below the current valley floor. A second basin was gouged out near Cathedral Spires (about 1,000 feet below the valley floor) and a third smaller one near the Cascades.
At the end of the Tioga Glaciation (the most recent event where a glacier flowed through the valley) a terminal moraine was deposited on top of the prior lake sediments. The road cut provides a cross section of this terminal moraine. The El Capitan Moraine created a final Yosemite Lake. As before, this lake continued to fill the valley with sediment.
Prior to 1897, the lake had not fully filled, and Yosemite Valley was swampy and mosquito infested. Annual floods continued to fill in the valley much as Mirror Lake is currently being filled (Mirror Lake, Mirror Meadow - Which one is it?). In 1897, the El Capitan Moraine was dynamited to create a deeper channel though it. This allowed greater drainage of the valley, eliminating the swamps and causing the Merced river to erode down in its channel. The dryer valley has also allowed pines to begin to grow in the valley floor.