Yoga and "yoke" are cousins: two descendants of one ancient root.
Sanskrit yoga comes from the root yuj, associated with attaching, joining and yoking. Etymonline traces it further to the Proto-Indo-European root yeug-, "to join." That root also gave English join, joint, yoke, junction and subjugate, plus Latin iugum, Greek zygon and Old English geoc.
The root appears in the Rigveda, in hymn 5.81.1 to the rising sun god, where Wikipedia says it suggests yoking or control. The word yoga in its familiar sense first appears in the Katha Upanishad, which scholars date anywhere from about the fifth to the first century BCE. There it means steady control of the senses.
Ancient grammarians were not sure of the root. Wikipedia reports that Panini, in the fourth century BCE, listed two possible sources: one meaning "to yoke" and one meaning "to concentrate." Traditional commentators on the Yoga Sutras prefer the second. So the "union" reading is the dominant dictionary one, but it is not the only ancient view.
The meaning moved from harnessing to discipline. The Bhagavad Gita, dated to around the second century BCE, calls yoga equanimity in success and failure and "skill in action." Patanjali's Yoga Sutras, from the early centuries CE, define it as "the stilling of the fluctuations of mind."
English picked it up from India in the 19th century. Etymonline records the word in 1820 as yogu, while yogi is older, from the 1610s. Wikipedia notes that N. C. Paul published a Treatise on Yoga Philosophy in 1851, and that Swami Vivekananda promoted yoga to Western audiences in the 1890s.
The postures most people now mean by yoga belong to a branch called hatha yoga. Etymonline dates "hatha-yoga" in English to 1911, formed from Sanskrit hatha, "force."