Use of "did" in an affirmative sentence before subject [duplicate]

  1. Only in June was it creating repositories.

  2. Only in June it was creating repositories. (ungrammatical)

In example (1) we see the auxiliary and subject change places. In example (2), the auxiliary and subject are the same as they would be in a normal sentence. It is ungrammatical.

  1. Only in June did it create repositories.

  2. Only in June it created repositories. (ungrammatical)

In sentence (3), again, we see subject auxiliary inversion. Sentence (4) has no auxiliary - this is because it has no inversion. However, it is ungrammatical.

Although we can insert auxiliaries for emphasis, the use of do is obligatory in the sentences above. It is not about emphasis. It is because we need to invert the subject and auxiliary verb. They have to change places. We can't do this if there is no auxiliary, so in sentence (3) we use the 'dummy' auxiliary DO so that we can create an inversion. Note that the main verb create can't be used for inversion:

  • Only in June created it repositories. (ungrammatical)

Moving only to the front of a sentence will trigger subject auxiliary inversion in main clauses under certain conditions. Here are some examples:

  • Only if we've received the papers can we release the prisoner.
  • *Only if we've received the papers we can release the prisoner. (wrong)
  • Only after the concert did I notice Pavarotti in the back row.
  • *Only after the concert I saw Pavarotti in the back row. (wrong)
  • Only in extreme circumstances did they steal.
  • *Only in extreme circumstances they stole. (wrong)
  • Only in the houses of parliament will you find this many cads.
  • *Only in the houses of parliament you will find this many cads. (wrong)

The grammatical sentences have certain features in common:

  • i) These sentences all have subordinate preposition phrases which occur before the main clause (phrases with if, before, after, during and so forth)
  • ii) These prepositions are always prepositions of time, place or condition.
  • iii) The head preposition in each case is being modified by only.
  • iv) Only must have the sense of not except in such examples.

When these conditions apply, subject auxiliary inversion will apply. Notice that although only modifies the subordinate phrase, the inversion occurs in the main clause. The subject auxiliary inversion does not occur in the subordinate clauses.

The Original Poster's Question

The main clause in the Original Poster question is a version of the canonical (normal) clause:

  • it created repositories.

However, this main clause is fronted by a temporal preposition phrase in June. This preposition phrase in June is being modified by the adverb only. This requires us to invert the subject and the auxiliary verb in the main clause. As we previously noted, the main clause is:

  • it created repositories.

There is no auxiliary in this clause - so we need to use the dummy auxiliary, do for the inversion:

  • did it create repositories.

This gives us the sentence:

  • Only in June did it create repositories.

Hope this is helpful!