Preventing natural signs from being printed when the key signature changes
Appearance
When the key signature changes, natural signs are automatically printed to cancel any accidentals from previous key signatures. This may be prevented by setting the printKeyCancellation property to #f in the Staff context.
\version "2.24"
\relative c' {
\key d \major
a4 b cis d
\key g \minor
a4 bes c d
\set Staff.printKeyCancellation = ##f
\key d \major
a4 b cis d
\key g \minor
a4 bes c d
}