Cape Government Railways
The Cape Government Railways (CGR) was the government-owned railway operator in the Cape Colony from 1874 until the creation of the South African Railways (SAR) in 1910.

History

Private railways
The first railways at the Cape were privately owned. The Cape Town Railway and Dock Company started construction from Cape Town in 1859, reaching Eerste River by 1862 and Wellington by 1863. Meanwhile, by 1864 the Wynberg Railway Company had connected Cape Town and Wynberg. For the moment, railway development at the Cape did not continue eastwards beyond Wellington because of the barrier presented by the mountains of the Cape Fold Belt.

Formation of CGR

The discovery of diamonds, and the consequent rush to Kimberley that started in 1871, gave impetus to the development of railways in South Africa. 
Shortly afterwards, in 1872, the Cape Colony attained responsible government under the leadership of Prime Minister John Molteno, who presented plans for an enormous network of railways to connect the Cape Colony's main ports to its interior and, importantly, to the Diamond fields. In his very first speech to the Cape Parliament he announced the purchase of all existing lines and the founding of the Cape Government Railways.

The announced expansion was to see the construction of a network over ten times more extensive than the total length of railway that existed in the whole of southern Africa at the time. The management of this system – which was to become the nucleus of the future South African Railways – initially fell under his Public Works Department, until July 1873, when Molteno established a separate Railway Department under the renowned engineer William Brounger.

Cape Gauge

The first few rudimentary lines at Cape Town were built at dimensions close to  , the British Empire's standard. However their width, designed for England's landscape, made it impossible at the time to penetrate the mountains of the rugged southern African escarpment. Most of the sub-continent was effectively landlocked. In 1871 Molteno had written to the British Governor of the Cape Henry Barkly about the gauge which was used to penetrate the mountainous terrain near Trieste in modern Italy, believing it would work in crossing the South African mountains. A narrower gauge enabled tighter turns and traversing steeper terrain. When the first elected Cape government took power the next year, its select committee set the gauge for all new railways at 3’-6”. The use of a dual system was briefly kept, to ease the transition for the existing wider lines, but in only a few months the government standardised all railway development on what became known as the "Cape Gauge" of .

Although it was first meant just to ease construction of railways through mountainous terrain, this gauge later went on to become the standard for all railways in southern and central Africa.

Expansion
The government's 1872 plan was for lines to strike northwards, from the three ports of Cape Town, Port Elizabeth and East London, towards Kimberley and the developing hinterland. These three lines became known as the "Cape Western", "Cape Midland" and "Cape Eastern" lines respectively. They were intended to bring the towns of southern Africa's vast hinterland into direct railway connection with the country's ports, thus driving the development of the interior and building an export economy.

The Cape Western Line was charted by the Prime Minister himself (allegedly with only a map, pen and ruler). Cape Town was cut off from the highland interior by a triple barrier of steep mountain ranges, but the lines nonetheless progressed fast inland, once the primary obstacle of the Hex River Mountains was overcome in 1876 with a major system of bridges and tunnels. 1876 also saw the building of a new central station for Cape Town, and over the next few years the line was rapidly extended through the Karoo desert to the town of Beaufort West, De Aar, and thence to Kimberley.

The Cape Midland Line was begun in 1872, when the Cape Government took over the rudimentary and incomplete line of the Port Elizabeth and Uitenhage Railway Company. However building accelerated massively over the next few years, with twin lines reaching northwards to Graaff-Reinet, and eastwards to Grahamstown. These connected with the Cape Western Line at De Aar and thus to Kimberley.

The Cape Eastern Line was built partially to serve the frontier, and its network of military forts. The port of East London was likewise chosen partly for strategic reasons, being the closest port to the frontier for landing and transporting troops. The line was begun in 1873, when the Prime Minister turning the first spades for both the East London harbour and the Eastern Railway Line on 20 August 1873. Though frontier wars disrupted construction from time to time, the line reached Queenstown in 1880. 

By 1885 the separate sections were connected and the Cape Western line reached Kimberley, marking the end of an epic which had begun in 1872, with the network completed faithfully according to the original 1872 plans. From an initial total of 92 kilometres in 1872, the Cape was now criss-crossed with over 2,000 kilometres of railway.

Considerable development and economic growth followed the construction of the railway system, and the news of the Cape's immense railway programme inspired similar moves in neighbouring states, such as the project of the Natal Government Railways to extend its few miles of railway inland towards the Drakensberg, and President Burgers' ill-fated attempt to link the Transvaal Republic to Lourenço Marques.

In 1886 gold was discovered in the South African Republic (the Transvaal), setting off the Witwatersrand Gold Rush. The Cape government and the government of the Orange Free State (OFS) reached an agreement, by which the Cape Government Railways would build and operate a railway line, through the OFS, to the rapidly growing city of Johannesburg. This line reached Bloemfontein (the capital of the OFS) in 1890, and the first trains operated from Cape Town to Johannesburg in 1892. In 1897 the OFS government took over control of its portion of the line.

Formation of SAR
The Cape railway network played a significant role in supporting and supplying the British forces during the Second Boer War. After the war, when the Union of South Africa was formed in 1910, all railways in South Africa, including the CGR, the Natal Government Railways and the Central South African Railways, were taken over by the newly formed South African Railways (SAR).

Impact
According to a 2017 study, "Built largely to support the early mining industry, the Cape Colony’s railway substantially reduced the cost of transport to the interior and account for 22–25 percent of the increase in the Colony’s labor productivity from 1873 to 1905... traffic data for 1905 suggest that the railway contributed to the expansion of the mining areas and to the growth of the Western Cape district on the basis of domestic demand."