Composite functions and one to one

I am stuck with a question,

Let $f: A\rightarrow B$ and $g:B\rightarrow C$ show that if $g\circ f$ is one to one then $f$ is one to one. Can anyone please help me out. I have no idea where to start with and how end it up.

Thanks


Suppose $x,y\in A$ such that $f(x)=f(y)$. Then $g(f(x)) = g(f(y))$. But this is the same as $(g\circ f)(x) = (g\circ f)(y)$ and $g\circ f$ being injective $\implies x=y$. This shows that $f$ is injective.


Suppose $f$ is not one to one, then there must be $x,y\in A,x \neq y$ such that $f(x)=f(y)$ and therefore $g(f(x))=g(f(y))$ but this means $g\circ f$ is not one to one and this is a contradiction. So $f$ must be one to one.