In elections to the Bundestag, or federal parliament, German voters cast two votes. The “first vote” is to elect a “direct” representative for their local constituency, much like in a British election; the candidate with the most votes wins the seat.
The “second vote” is for a party list, as in many European countries. The refinement of the German system is that the overall membership of the Bundestag is designed to be proportional to the second vote. To achieve this, any overrepresentation resulting from the directly elected seats is compensated for by adding more seats to the parliament.
This means that the size of the parliament can vary based on how the votes are cast, but at the end of the process if the Greens get 20% of the second vote, they should and usually do get very close to 20% of the seats.
There are two last details that affect the assignment of seats. The first is that a party needs to cross a 5% threshold in the second vote to enter parliament. So in reality, the seats are awarded proportionally to the parties that do cross the threshold, based on their share of “successful” second votes. The other detail is that a party which wins three or more seats in the first vote does not have to meet the 5% threshold.
Once the calculations are complete, the parties typically spend a number of weeks in coalition negotiations. Only when these are complete does the Bundestag vote to elect the chancellor.