In English we are pretty casual about the word “same,” but German makes some important distinctions. Let’s see how.
Earth has only one moon, so when we say we see the “same” moon, there’s no question. We're talking about one and the same. That’s when, in German, we use the demonstrative pronoun, derselbe (or any of its declensions, which you can see here). In this particular case we have a masculine noun, der Mond in the accusative case, so derselbe becomes denselben:
Wir sehen denselben Mond
We see the same moon
Und wir sind größer, denn die Sterne bleiben stehen
And we are bigger, because the stars stand still
Captions 13-14, Kolkhorst - Der MondPlay Caption
In the next example, we can see that Charlie and Raymond have discovered they are brothers. They have the selfsame parents. Once again, we want derselbe. Der Vater is masculine and is in the accusative case, so it gets denselben. Die Mutter is feminine so it gets dieselbe.
...als Charlie erfährt, dass Raymond und er
...when Charlie learns that Raymond and he
denselben Vater und dieselbe Mutter haben.
have the same father and the same mother.
Caption 23, Theater - Rain ManPlay Caption
But sometimes we say things are the same when they only appear to be. They may be very similar, or one a copy of the other. That’s when we use gleich or der gleiche. It’s a normal adjective, so it changes depending on gender and case. Below, the speaker describes a recurring event:
Es ist leider noch immer jedes Jahr das Gleiche.
Unfortunately it is still the same every year.
Caption 1, Für Tierfreunde - Tierheim NiedPlay Caption
Singer-songwriter Cassandra Steen talks about making mistakes: two separate ones, but of the same kind. You guessed it. It has to be der gleiche!
Wenn Aussagen ignoriert werden.
When statements are ignored.
Wenn der gleiche Fehler zweimal passiert.
When the same mistake happens twice.
Caption 4, Cassandra Steen - InterviewPlay Caption
Note that when we use der gleiche, the article is separate from the word. But when we use derselbe, dieselbe, or dasselbe, the article is connected to the word. In either case, the article to use and the ending of "gleich" or "selb" depend on the gender and case of the noun being modified.
Hopefully you’ve gained some insight on the German way of talking about things that are “the same.” You may never think about the word “same” in the same way again!
More advanced learners will enjoy this explanation, in German, from Spiegel Online Kultur.