The Pauli Exclusion Principle states that, in an atom or molecule, no two electrons can have the same four electronic quantum numbers. As an orbital can contain a maximum of only two electrons, the two electrons must have opposing spins. This means if one electron is assigned as a spin up (+1/2) electron, the other electron must be spin-down (-1/2) electron.
Electrons in the same orbital have the same first three quantum numbers, e.g., n=1, l=0, ml=0 for the 1s subshell. Only two electrons can have these numbers, so that their spin moments must be either ms=−1/2 or ms=+1/2. If the 1s orbital contains only one electron, we have one ms value and the electron configuration is written as 1s1 (corresponding to hydrogen). If it is fully occupied, we have two ms values, and the electron configuration is 1s2 (corresponding to helium). Visually these two cases can be represented as
(Chem LibreTexts)
The 2nd case is correct because the difference of spins in the 2s orbital mean that the electrons do not share all 4 quantum numbers,
satisfying the Pauli Exclusion Principle. In effect, the above example shows that for each n shell, l shape, and ml orientation (in the picture each box), there can
be a maximum of 2 electrons and if there are 2, they must have opposite spins.