Your scenario is too vague to be of use. Post links to the games that you mentioned.
How should I protect the G file?

I'd stop the clock, call the arbiter over, and claim an illegal move.
Aww :(
Well the answer always depends on the position. If it's not a threat, then don't respond to it. Moving pawns in front of your king makes it a bit easier to attack.
So when you ignore it, spend moves on creating play somewhere else. The classic response to a flank attack is to open the center and seek play there. If the center is locked you can also try to get things going on the queenside.
If you can't do anything but defend, then you probably did something wrong earlier in the game. However if you do find you're stuck defending then as I said in the beginning, try not to move the pawns in front of your king. Instead bring pieces (non-pawns) over to help defend your king.
If they're only attacking with 1 or 2 pieces, then just ignore it. That's not enough pieces to be effective.

Generally: Try to avoid "castling into the attack" i.e. Don't place your King at the end of a half-open file.
Specifically: 15. g3 is asking for trouble. Did you notice that you're a piece up?
When ahead on material, the safest route to victory is usually simplification:

Trading pieces was good advice. Not panicking is also good advice.
Notice if you had just played 15.Nf3 and then calculate the worse case scenario. Bh3 g3 and you lose the exchange. You've gotten two pieces for a rook... and that's worse case scenario. g3 is a huge overeaction.
As estragon said you can defend g2 easily with a knight or bishop. So 15.Nf3 and you keep your extra piece, super easy. (although as doggy said you can also defuse the attack with exchanges, which is even better).
So when you're under attack stop and identify the specific threat. If you play with a vague sense of doom then you'll fall apart. After identifying the specific threat, you can look at moves to defend it. In this case you could have noticed there is no big threat and you can just keep your extra piece.
Moves like 18.a3 are bizarre. Passing moves are suspect enough, but to make one when you're under attack? This suggests to me that the time control was much too fast, 15 moves into the game you can't make basic evaluations anymore. Play games where you have enough time to make an assessment, find the threat, and play a reasonable move.
Hi there,
A situation that occured to me several times and apperantly i do not know how to handle correctly.
For discussion sake, let`s say I play white. I castle and all pawns of the king wing are in their original position :f2,g2,h2.
Now, black plays a move in which he controls the entire g file. For discussion sake, he move the black rook to g6.
My question is: what is the best defence strategy? What I usually do, is g2g3 that made me lose several games.
What do you think?
I am attaching a screenshot. Please ignore all pieces that were not mentioned in this question.
Tnx