A continuity tester would be able to identify the wiring for you.
It may be possible with much effort to physically trace the wires if you were to undo the nut at the base of the light fitting and separate the two halves but this could lead to there being lots of bits of light fitting all over the place and tracing wires through the flex is very hard.
The wires do show in the pictures that there is a grey stripe on at least one of the wires, though it may be on all of them, and so this might help tracing.
The wires should be one line, one neutral and one earth, the polarity of line and neutral will not matter on a G9 lamp but the earth identification is crucial to avoid an electric shock.
Even if you have a bulb and a battery with bits of wire to make a circuit you can use this on the wires (when disconnected from the mains supply) of the light fitting to trace them. The G9 lamp holder will have two contacts, one to either edge of the slot, make sure you are not shorting across the contacts and getting false readings.
One wire should go to one side of the lampholder, one wire to the other side of the lamp holder and the earth wire to the metal casing of the light fitting (similarly to the green wire you have already).
View attachment 35010