If you'd like to, click here to open Matthew 1 in a new tab, and click here to open Luke 3 in a new tab. I didn't want to reprint the entire chapters here.
The two genealogies of Jesus given in Matthew 1 and Luke 3 are quite different from one another. For example, who was Joseph's father?
Matthew 1:16
16 And Jacob begat Joseph the husband of Mary, of whom was born Jesus, who is called Christ.
Luke 3:23
23 And Jesus himself began to be about thirty years of age, being (as was supposed) the son of Joseph, which was the son of Heli,
The answer to this alleged discrepancy is that Matthew is tracing Joseph's lineage, and Luke is tracing Mary's lineage.
We can deduce that Matthew is Joseph's lineage because it lists Jeconiah (Greek version "Jechonias" - Matthew 1:11), of whom it was prophesied "no man of his seed shall prosper, sitting upon the throne of David" (Jeremiah 22:30). Obviously, Jesus was not the "seed" of Joseph. Giving Joseph's genealogy is to establish the fact that Jesus is descended from David on both sides - both legally (Joseph, descended from David's son Solomon - Matthew 1:6) and physically (Mary, descended from David's son Nathan - Luke 3:31).
That means that Heli is Mary's father, and Joseph is Heli's son-in-law. If Mary didn't have any brothers, then Joseph would also be treated as the full son of Heli for inheritance purposes (Numbers 27).
Therefore, the solution for the discrepancies is that we are tracing the lineage of Jesus's legal "father" in Matthew and His mother in Luke.
Also note that you have to be careful how you read genealogies in Scripture.
The way that God counts generations is not always one-for-one. What we get are the generations that God cared to list or chose to emphasize for whatever reason.
Also, "begat" does not always denote a father-son relationship. For example:
Matthew 1:8
8 And Asa begat Josaphat; and Josaphat begat Joram; and Joram begat Ozias;
The actual father of Ozias (Greek version of Uzziah) was not Joram:
2 Chronicles 26:1
1 Then all the people of Judah took Uzziah, who was sixteen years old, and made him king in the room of his father Amaziah.
Uzziah's father was Amaziah, Amaziah's father was Jehoash, Jehoash's father was Ahaziah, and Ahaziah's father was Jehoram (alternate spelling of Joram).
That means that even though the lineage in Matthew says "Joram begat Ozias", we are denoting a great-great-grandson relationship. "Begat", then, simply denotes a familial relationship, not necessarily father-son.
Each genealogy traces a different parent of Jesus. They do not contradict.