The seats in the Bundestag are parceled out in proportion to shares of the national vote among federally recognized parties, and each party has a list of candidates who may or may not get a seat from that party's resulting allotment, based in part on the popularity of those candidates in their local list elections. The math of it is a bit more complicated than that, but it works quite well to completely sidestep the gerrymandering problem. The flipside is that parties must be registered federally to participate, and this gives the government a great deal of implicit power to exclude parties it doesn't like.
CGP Grey has a good YouTube video explaining it, probably better than I have here [2].
[1]: https://thumbs.dreamstime.com/z/german-election-ballot-paper...