When you start a new game, it looks over all the .girlsx files and compiles them into the savegame file in the <Girls> section.
The game also marks what .girlsx files have already been loaded in the <Loaded_Files> section.
When you get a girl, she is moved to one of the <(building)_Manager> sections of the savegame.
When a savegame loads, it only loads new.girlsx files that are not in the <Loaded_Files> section.
If you change a .girlsx file, you need to remove that file from the <Loaded_Files> section and the girl form wherever she is in the rest of the sections.
.rgirlsx files are totally different, the game does not store anything about .rgirlsx file.
It has been a while since I looked at some of this code so I may miss a few things.
The majority of the girl handling is in cGirls.cpp
During the game, these are some of the functions that handle girls:LoadGirlsXML - Loads .girlsx files into the game
LoadRandomGirlXML - loads .rgirlsx files
AddRandomGirl - tracks the type of rgirl?
CreateRandomGirl - creates a random girl
GetRandomGirl - randomly chooses a girl from <Girls>
I could go on but this should be a start for you.
If you need more, ask.