How to differentiate elements that have same spectral lines in a star? Suppose that iron and calcium have a spectral line with the same wavelength. How would you determine which element is present in the atmosphere of a star if you found this line in its spectrum?
If you only had that single line, you would be unable to differentiate them.  This is especially true of redshifted objects where we couldn't tell the actual wavelength of an isolated peak.  But a good spectrograph will give you information over a range of wavelengths.  

Each element has multiple lines.  It is the overall pattern of relative strengths that is definitive.  

As an example, the stronger lines for a few elements are shown below:


(From https://cnx.org/contents/LnN76Opl@10.1:H5KhIDcK@3/Spectroscopy-in-Astronomy)

You can see there's a cyan line that is similar in both hydrogen and calcium.  But the other lines are so different, you could tell if one or both were present, even if they were overlaid on a single chart.