"Jerry" as a term for German troops is probably a diminutive of "German". It was in use by British troops in France by early 1916. The Daily Express quoted it in March 1916 and in September 1916 explained it as " "Jerries" - That is the "official" Irish designation of the enemy." It does not appear to have been a particularly derogative term.
The term "Tommy" is an abbreviation of "Thomas Atkins", a generic term for British soldiers since at least 1815 when the British War Office released the "General Regulations and Orders" with sample forms and directions for record keeping where the forms showing how to complete soldiers records used the generic name "Thomas Atkins" as an example. The usage of the name as an exemplar for forms continued to appear in the 1832 version of the direction "On The Enlisting, The Discharging, and The Pensioning of Soldiers" and has continued. By the 1860s, soldiers were commonly using the term in reference to themselves. There is a complaint letter in the Soldiers Gazette of 1864 signed by "Tommy Atkins". In 1890 Rudyard Kipling wrote the poem "Tommy", published in the collection "Barrack Room Ballads" which established the term as an identifier for the British soldier throughout the English speaking world.