If you are a EU/EEA citizen, you only need to register at the next citizens' service office (Bürgeramt). You should make an appointment with one of the more than 40 Bürgerämter in Berlin about 2-3 months before your arrival, as you have to register within two weeks after moving to your new apartment.
If you are a citizen of Australia, Israel, Japan, Canada, New Zealand, South Korea, or the United States of America you may obtain any residence permit that may be required after entering Germany. The same applies to citizens of Brazil and El Salvador, given that they come to Germany for study purposes and do not seek employment. This information is without guaranty. Please check by yourself if it still applies for your country.
Citizens of all other countries who intend to study in Germany must apply for an entry visa at the competent mission before arrival.
If in doubt about whether you need a visa in order to study in Germany please check the list offered on the webpages of the German Federal Foreign Office (also here for information from Studying in Germany).
Once you have received the official admission letter from the university where you will be enrolled, you can submit an application for a student visa to the respective German mission abroad. The German mission abroad will then forward the visa application for an opinion to the foreigners' authority (Ausländerbehörde) in the town housing the university, i.e. Berlin. The German mission abroad can only issue the entry visa once the foreigners' authority has given its approval. Details on the documents to be presented with your visa application are often available on the webpage of the competent German mission abroad or directly from the mission itself. More information is available here (in German).
Visa application forms for a long-term stay (longer than three months) can be obtained from the relevant mission free of charge or online. Please contact the mission beforehand to find out exactly which forms and other relevant documents are required.
The approval procedure usually takes up to three months, in some cases longer, since the foreigners' authority will normally consult with other authorities.
Students of the TU Berlin can apply for the extension of their residence permit at the visa service of the TU Berlin as long as it is not expired yet. Unfortunately, the website is only available in German - if you need any help, please contact the BCCN teaching coordinator!
A similar service is also offered for students of the HU Berlin. Please find all information on the website of the HU visa service for students.