Sonata in G major for two flutes and basso continuo, BWV 1039

The Sonata in G major for two flutes and basso continuo, BWV 1039, is a trio sonata by Johann Sebastian Bach. It is a version, for a different instrumentation, of the Gamba Sonata, BWV 1027. The first, second and fourth movement of these sonatas also exist as a trio sonata for organ.
Historical context.
This sonata, scored for two transverse flutes and continuo, is one of the few trio sonatas that can genuinely be attributed to Bach. Although traditionally thought to have been composed during Bach's period in Weimar or Cöthen, Bach scholars have revised that dating based on an analysis of the extant manuscripts and on stylistic considerations. According to , the trio sonata was composed between 1736 and 1741 in Leipzig, where, since 1729, Bach had been director of the Collegium Musicum, a chamber music society performing weekly at the Café Zimmermann. The version for viola da gamba and harpsichord, BWV 1027, as well as the other two sonatas for this ensemble, are dated by Laurence Dreyfus, Christoph Wolff and others to the same period.
Movements.
BWV 1039 has four movements:
Trio sonata for organ.
Apart from the sonata for viola da gamba and the trio sonata for two flutes and continuo, there is a third version of the sonata for organ—the trio sonata in G major in three movements (BWV 1027a and BWV 1039a). The first two movements are organ transcriptions of the first two movements of BWV 1039; while its last movement is a transcription of the fourth movement of BWV 1027. According to the Bach scholar Russell Stinson, the transcription for organ was not made by Bach, but probably by Johann Peter Kellner. Peter Dirksen has surmised that although the Gamba sonata BWV 1027 corresponds to one of Bach's own autograph manuscript from 1740, the other sources, one of them with Bach's son Johann Gottfried Bernhard as scribe, probably date from 1735 or later. Stinson also thinks it possible that the organ arrangement could originate from a lost trio sonata in G major for two violins and basso continuo.
References.
Scores, manuscripts and catalogues
Commentary