Genesis 36 gives the history of the descendants of Esau ( called Edomites). Esau had three wives, two from Canaan and one was his cousin. He had 5 sons in all that were born to him in Canaan. When Esau's household and goods and livestock became too great, they moved away from Jacob's household to the hills of Seir, since the land could not support both households.
Genesis 37 begins with an account of Joseph tending flocks with his brothers. Joseph was Israel's ( =Jacob's) favorite son and his brothers despised him for that. Furthermore, Joseph had shared some of his dreams with his brothers, in which he was a ruler over the people. His brothers were jealous even more, but Israel took the dreams into consideration. Later, when the brothers were out with the flocks, Israel asked Joseph to go check on them to see if all was well and then return to report their status. When the brothers saw him coming they plotted to kill him, but instead decided to throw him into a deep pit and then tell their father that wild animals must have eaten him. Then some traveling merchants came by and the brothers sold Joseph to them as a slave and he was taken to Egypt. The brothers took Joseph's coat and dipped it in goat's blood and brought it to their father. Israel believed that Joseph had been killed by some ferocious animal and he mourned for many days and refused to be comforted. Joseph was sold by the merchants to Potiphar, and official of the Egyptian Pharaoh.