Deutsche Bahn AG (DB) is the German national railway company. Virtually all active train stations, all long-distance trains and and many regional trains and S-Bahn city trains are run by them.
Most regions of Germany offer some kind of transportation network, local DB trains are usually included and tickets from both of them are valid, although the pricing might be very different.
The normal fares are very expensive and usually not used by locals. The DB is actualy the 2nd most expensive railroad in Europe after the Norwegian. There is a wide range of special offers and rebate systems, but they are rather difficult to use for single spontaneous trips. Some exceptions are the Schönes-Wochenende-Ticket (Happy-Weekend-Ticket), the Quer-durchs-Land Ticket and the regional day ticket Länderticket.
The Schönes-Wochenende-Ticket is valid for a whole Saturday or Sunday for up to 5 persons in all regional trains in all of Germany. It used to be possible to "hitchhike" this ticket because it was valid for up to 5 people for a flat cost of 40 Euro. Because it was so cheap, many people bought it even though they were alone or in groups smaller than 5, so it was possible to join a group for free. Now, the ticket costs 40€ for one person and 4 Euro more for each additional person. Since you have to select the number of passengers beforehand, joining existing groups isn't possible anymore, and you will likely have to pay a share of the price.
The Quer-durchs-Land Ticket does the same on weekdays, but is slightly more expensive at 42 Euro for the first person and 6 Euro more for each subsequent. On weekdays you can use the Länderticket, which is about 20 Euro for one person or 30 Euro for 5 persons in all regional trains from 9:00 unto 3:00 the next day in a certain Federal State (sometimes several count as one).
The golden days of the weekend ticket are, sadly, over. The so-called Schönes-Wochenende-Ticket still exists, but you now have to select the number of passengers at the time of buying, and each additional person (up to 5), costs 4 Euro. This means that you might still be able to spontaneously find people to share a ticket with, but you will have to approach them before they buy the ticket (so no asking around when you're already in the train), and you will likely have to pay at least 11 Euro (per-person price in a group of 5). Theoretically, though, people might let you join their ticket for 4 Euro, or even pay the 4 Euro for you, but, arguably, neither of those possibilities could be called hitchhiking.
It is also possible to join Ländertickets, but they are not as common and there is a cheaper Single version which is not useful because you cannot join it.
In some regions like Dresden, Cologne and Aachen people are also allowed to take somebody on their student ticket, job ticket, monthly ticket or year ticket in afternoons and on weekends. This might be noted in the city articles.
In Berlin, you can hitchhike public transport with people who have monthly tickets, but only on weekdays from 8 pm - 3 am, and the whole day on Saturdays and Sundays. People might be confused if you ask them about it, since it's not very common, but finding someone with a monthly ticket shouldn't be a problem since they are very widespread. Ask people if they have a so-called "Umweltkarte", the most common ticket with the possibility to hitchhike, or see nomadwiki for more details.
On long distance trains (IC and ICE) you can buy a ticket from the conductor (the fare being 10% higher), which can make blackriding difficult. If you cannot pay on the spot (or at least say so), the conductor will print a fine if you present ID. Many conductors will issue a fine that serves as a valid ticket to your declared destination, and provided you're not a German citizen or resident, you can disregard this penalty. This is not a foolproof method, however, as certain conductors will only issue a fine valid as a ticket to the next station, and force you to get off the train there.
For example, I myself went on an ICE from Siegburg/Bonn to Basel ticket-less, getting caught before Frankfurt airport. Showed the conductor my ID, provided a fake German address (I live elsewhere) and was given a fine valid as a ticket all the way to Basel.
Another time I boarded a Hamburg-bound ICE in Freiburg wanting to go to Hamburg. Made the mistake of sitting in a compartment, where I was successfully identified as a new passenger. Despite insisting I could pay a fine all the way to Hamburg, the conductor only gave me a fine to the next stop, Baden-Baden, where I was then kicked off.
Boarding a train at an intermediate stop ticket-less works well in busy long-distance trains. If there are many passengers on the train, your appearance is normal and you don't stick out in the eyes of the staff, you're unlikely to be identified as a new passenger. They will walk through the train asking who is new ("Neu zugestiegene Fahrgäste?"), and if you don't react, they'll normally keep walking. For this purpose, however, always sit in the open salon, where you'll blend in much easier, and not in a compartment.
If you fall asleep (or pretend to), there is a chance that the conductor doesn't want to wake you up. Wearing headphones might help. Check the fares beforehand anyway, because they are pretty high.
The short-distance ticket trick works well on long-distance trains, at least busy ones. Even if sitting in a compartment, once the staff has seen your ticket and stamped it, they will rarely remember the stated destination of each passenger.
In some regional trains (S-Bahn, RegionalBahn or RegionalExpress), such as from Singen to Schaffhausen (Switzerland) ticket checks are fairly common, while on others they're the exception and thus a great way to blackride across the country. The same instructions apply regarding fines.
On some regional trains, there is a ticket machine. This varies from region to region, so you should check it before. If there is, you could try checking if there actually is a conductor on the train before buying a ticket. Multi-wagon trains and conductors joining the train at a later stop make this somewhat risky though. You're obligated to posses a valid ticket as soon as you join the train so you can get fined even in the process of buying if you're considered a blackrider.
- If you're a German citizen/resident and they get your ID, it means you'll be donating from 60 EUR to the full ticket price to the DB's shareholders (mostly the German state, if that makes you feel better) − if they don't, you might be tempted to give them a fake name and address, which, while, illegal, will work.
- You don't have to pay instantly, but usually by bank transfer within 10 days
- As a last line of defense, conductors can call the police and legally keep you from leaving to prevent you from "illegally obtaining a service". Most commonly, however, you can get a fine printed that is valid as a ticket to your declared destination, or you may simply be kicked out at the next stop.
- For persons neither citizens nor residents of Germany, the penalty cannot and will not be enforced. As mentioned above, if given your ID, many conductors will print a fine valid as a ticket to your intended destination, making this a useful method for visitors to blackride. Beware, however, that not all conductors will agree to this, and they may insist that you get off at the next stop.