I came across 2 books one of which said that Ganga is married to Shiva while the other one said she is married to a Gandharva. So what is the correct relation between Ganga and Lord Shiva?
Gangs is not married to lord Shiva. She is Goddess parvati's sister.Due to Maharaj Bhagirath's meditation Ganga came down from heaven on earth but her force was so large that if she would directly fall on earth, earth would get destroyed and so Lord Shiva took her in his "jata", that's why we see ganga coming out of his hair. That's how he allowed ganga to flow on earth slowly.Things like this happened and Ganga's name is taken with shiv at times. Once even Mata Parvati was suspecting Shiv to be loving Ganga not her and she moved out of Kailash and took another form. But Shiv only has one wife and that's Parvati
As mentioned in Valmiki Ramayana
Ganga descends to earth by the extraordinary effort of Bhageeratha. Shiva agrees to the alighting of Ganga on His head and from where she is released into a lake called Bindusarovar, and from there she flows in seven courses. On land Bhageeratha ushers her up to netherworld dug by his ancestors where heaps of ashes of his grandparents are there, and she enters accordingly to inundate those mounds of ashes according salvation to the souls.
Reference-Valmiki Ramayana, Book I : Bala Kanda - The Youthful Majesties chapter/Sarga 43
Yes Ganga is married to Shiva. The story comes from the Devi Bhagvatam Book 9 Chapter 6:
16-21. Nârâyana said :-- Hear, O Nârada! I will now describe that incident, the hearing of which removes all the sins. Laksmî, Sarasvatî and Gangâ, the three wives of Hari and all equally loved, remain always close to Hari. One day Gangâ cast side-long glances frequently towards Nârâyana and was eagerly looking at Him, with smile on Her lips. Seeing this, the Lord Nârâyana, startled and looked at Gangâ and smiled also.
Laksmî saw that, but she did not take any offence. But Sarasvatî became very angry. Padmâ (Laksmî) who was of Sattva Guna, began to console in various ways the wrathful Sarasvatî; but she could not be appeased by any means. Rather Her face became red out of anger; she began to tremble out of her feelings (passion); Her lips quivered; and She began to speak to Her husband.
Lord Vishnu, perhaps realizing that he should best remain out of the women's quarrel quietly left the place and after his departure Saraswati tried to attack Ganga. Lakshmi tries to intervene so gets cursed by Saraswati to turn into a river. Seeing this Ganga gets angry and curses Saraswati:
39-44. Thus saying, Gangâ became ready to curse Sarasvatî and addressing Laksmî, said :-- “O Dear Padme! As that woman has cursed you to become a river, so I too curse her, that she, too, be turned into a river and she would go to the abode of men, the sinners, to the world and take their heaps of sins.” Hearing this curse of Gangâ, Sarasvatî gave her curse, “You, too, will have to descend into the Bhurloka (the world) as a river, taking all the sins of the sinners.”
When all the action is over Lord Vishnu returns and calms them down. He tells them that their curses and counter curses can't be nullified and they would have to face the consequences of their jealousy:
O Gange! You will also have to take incarnation in Bhârata as a river, purifying all the worlds, to destroy the sins of the inhabitants of Bhârata. Bhagiratha will take you there after much entreating and worshipping you; and you will be famous by the name Bhagirathî, the most sanctifying river in the world. There, the Ocean born of my parts, and the King S'ântanu also born of my parts will be your husbands.
After he has clarified that they would indeed have to be born as rivers he asks Ganga and Saraswati to leave him and take residence with Shiva and Brahma respectively while only Lakshmi was to remain with him due to her Satvik nature:
O Bharatî! Let you go also and incarnate in part in Bhârata under the curse of Gangâ. O Good-natured One! Now go in full Amsas to Brahmâ and become His wife. Let Gangâ go also in Her fullness to S'iva. Let Padmâ remain with Me. Padmâ is of a peaceful nature, void of anger, devoted to Me and of a Sâttvika nature.
Therefore, Ganga became Shiva's wife as a result of the events that were set in motion by Sarwaswati's curse. However, later she was married to Shantanu who in his previous birth was a denizen of Swarga called Mahabheesh (but not a Gandharva). She gave birth to Bhishma Pitamah the grand old patriarch of Kuru Dynasty in the Mahabharat.