Going up in the morning a comfortable train ride from Oakland / Emeryville to Merced takes about 3 hours and then YARTS motor coach to Yosemite Valley takes about 2 hrs and 15 minutes.
Here is some important information
The distance between San Francisco and Yosemite is 215 miles (345 km). Driving time in a car is at least 4 hours, in a bus about 30 minutes more each way. Several tour companies operate sightseeing trips for the day that take at least 15 hours. Those using large 40 or 45 feet motor coaches seating up to 55 passengers have space for luggage. Others using mini busses or vans charge for the space taken up by your baggage if it cannot fit under the seat.