The OED has four different meanings for the phrase no shit, summarised:
A. interjection:
1. a. A response expressing incredulity, 'Is that so?'
1. b. A sarcastic response to a banal statement, 'No shit, Sherelock!'
2. Affirming one's one statement, 'That's the truth'
B. adjective: Genuine, no frills
They say it's originally US slang with a first citation (for A.1.a.) from 1939 in A. C. Bessie's Men in Battle. A story of Americans in Spain:
‘Sure, they're going to withdraw the volunteers from Spain.’ ‘No shit,..and here I was planning to..grow up with the country.’
For the 'stating the obvious' meaning of the question (A.1.b.), the OED's first quotation is from 1966 in N. Hentoff's Call Keeper:
I..explained what the series was all about... ‘It may show people they're not as different from everybody else as they thought.’ ‘No shit! Imagine that.’