Here’s an example from Bach’s Fugue in Ab major from WTC book 1:
In the last bar of this image you can see they put an Ab in the left hand and a G natural in both the left and right hands. Since this piece is already in Ab and the measure has no accidentals preceding these notes, what is the reason for using the accidentals here? It seems entirely unnecessary. Also, the measure in front of it uses a Gb in the right hand and an A natural in the left hand, so I'm wondering if this is just a courtesy to the reader?
To be clear, this is one simple example, but I've seen this a whole bunch in music from many different time periods. I've seen places where they do this the measure after like in this instance, but obviously there are times when they don't do this too. What are the rules here?
