The different railway companies in Germany have used various schemes to classify their rolling stock.

From the beginning
As widely known the first few locomotives had names. The first locomotive in public service in Germany from 1835 was named Adler. The first railway lines were built by privately owned companies. That changed later when many railway companies were taken over or founded by the respective German states such as Prussia, Bavaria, etc.

Different numbering schemes prior to 1924
The fast-growing number of locomotives made a numbering scheme inevitable. Most of the various state-owned German railway companies (called Länderbahnen in German) developed their own schemes, e. g. the Prussian state railways (preußische Staatseisenbahnen sometimes erroneously referred to as the Königlich Preussische Eisenbahn-Verwaltung or KPEV) introduced P for passenger train locomotives (the P 8 was one of the most important locomotive types with a total of over 3,000 units built), S for Schnellzug (express train) locomotives (e. g. the famous S 10), G for Güterzug (freight train) locomotives and T for Tenderlokomotive (tank locomotive). Basically the numbers were used continuously. As the Prussians also standardised technical standards, some of the smaller companies also used the Prussian numbering scheme or a similar one.

Bavaria's state-owned railway chose a different way: They also used P, S, or G to indicate the train type, but combined with the numbers of driving axles and of the axles in total, separated by a slash (similar to the Swiss system). E. g., the famous S 3/6 was a 2'C1' or 4-6-2 Pacific, meaning that of a total of 6 axles, 3 were driving axles.

These various state-owned companies and thus their numbering schemes were retained after German unification in 1871 and kept until well after World War I.

The first uniform scheme

The Deutsche Reichsbahn-Gesellschaft DRG was founded in 1924 by the amalgamation of the various state-owned Länderbahnen. One of its first tasks was to introduce a numbering scheme that allowed to integrate the existing various pre-DRG classes.

Steam locomotives
For steam locomotives, the system was purely numeric. Every locomotive received a unit number, consisting of the number for the class (in German Baureihe, abbr. BR), and an ordering number, separated by a space. The class numbers 01 to 19 indicated express train tender locomotives, numbers 20 to 39 passenger train tender locomotives, 40 to 59 freight train tender locomotives, 60 to 79 passenger train tank locomotives, 80 to 96 freight train tank locomotives (including switchers), 97 rack locomotives, 98 Lokalbahn (local railway) locomotives and 99 for narrow gauge locomotives. Besides, the DRG constructed the so-called Einheitslokomotiven (unified or standardised locomotives) to renew rolling stock and to overcome the expensive necessity of keeping dozens of different classes with hundreds of different parts. For example, Class 01 was the first class of unified express train locomotive, and the first unit of this class received the number 01 001.

Electric and diesel locomotives
In addition, similar numbering schemes were introduced for electric and diesel locomotives, but with prefix letters E for electrics and V (from German Verbrennungsmotor for internal combustion engine) for diesels. For electric locomotives, the class numbers roughly followed the scheme for steam locomotives, e. g. E 18 22 was a locomotive from the class E 18 introduced in 1935. Diesel locomotives received class numbers indicating one tenth of the horsepower rating (according to the original design), e. g. V 80 001 was the first unit of class V 80 introduced by the DB in 1953 with originally 800 hp (later re-engined to 1100 hp).

Multiple units and railcars
Electric and diesel railcars and multiple units were designated by prefix letters ET and VT, respectively (from German Elektrischer Triebwagen and Verbrennungsmotortriebwagen). The numbering schemes for those were originally derived from the numbering scheme for passenger carriages. However, in 1940 a system using class and ordering numbers, like for locomotives, was introduced for electric multiple units. A plan to introduce a similar system for diesel railcars and multiple units was put on hold due to World War II; in post-war Western Germany (FRG), the Deutsche Bundesbahn eventually followed through while in Eastern Germany (GDR), the Deutsche Reichsbahn continued to use the pre-war system for pre-war vehicles while starting off several new numbering plans for post-war units over the years, thus ending up with a hodge-podge of conflicting schemes for diesel railcars and multiple units until 1970.

IT compatible numbering schemes
Due to the introduction of computers/IT in the late 1960s it became necessary to revise the numbering schemes, as the old numbers could not tell whether a class 10 might be a steam or an electric locomotive without including the prefix letters, which were difficult to process by computers of the day. Another problem was both class and ordering numbers could vary in length under the old system.

DB numbering scheme

The Deutsche Bundesbahn (DB) in Western Germany decided to use three-digit class numbers, with first digit 0 for steam engines (the rest of the scheme was basically unchanged), first digit 1 for electric locomotives (scheme for second and third number also unchanged), first digit 2 for diesel engines, first digit 4 for EMUs, first digit 5 for battery-powered EMUs, first digit 6 for DMUs, first digit 7 for rail busses (light DMU) and service vehicles. Ordering numbers were uniformly three-digit as well (shortened or filled out from the previous version where necessary) and a check digit separated by a hyphen was added to the end, resulting in a uniform length of seven digits (including the check digit) for all unit numbers. For the few classes with existing ordering numbers of four digits, such as class 50 (new base class number 050), the class number was extended into unused adjacent numbers 051, 052 and 053, the third digit being the first digit of the previous ordering number.  Thus, e. g. the old electric express locomotive E 18 22 received the new number 118 022-3. The new DB system came into effect January 1, 1968 (although the actual conversion spread out over several years) and effectively continues to be in use today.

DR numbering scheme

In contrast, the Deutsche Reichsbahn (DR) in Eastern Germany also introduced a numbering scheme with seven-digit unit numbers (including check digit), but continuing to use two-digit class numbers for steam locomotives (thus providing for four-digit ordering numbers) and three-digit class numbers for diesel and electric vehicles (which therefore also had three-digit ordering numbers). As a further contrast to the new DB system, the DR decided to use the first digit 1 for diesel and the first digit 2 for electric vehicles (including both locomotives and multiple units/railcars). Therefore, e. g. the DRG-built E 44 class was renumbered 144 by the DB and 244 by the DR. To avoid clashes between steam and electric/diesel unit numbers (the space separating class and ordering number being non-significant in computer processing), steam locomotive class numbers in the 10-19 and 20-29 number ranges were reassigned to the 01-09 and 30-39 number ranges, respectively (e. g. the steam locomotive with the old number 23 1046, built in 1958 for the DR, received the new number 35 1046-8). This new DR system came into effect January 1, 1970.

After German reunification
After German reunification the DB number scheme was also introduced to DR locomotives (effective January 1, 1992), thus creating some numbers that were used again (e. g. the former Class 120 diesel-electric engine became class 220 (new), with Class 220 (old) already removed from service). Some numbers had to be changed to avoid double numbers, e. g. former Class 211 became Class 109.

See also
History of rail transport in Germany
Deutsche Reichsbahn
Deutsche Reichsbahn-Gesellschaft
UIC classification

Encodings
Locomotive classification systems
Locomotives of Germany