Why the integral of $\frac{1}{z}$ over a closed curve is not $0$. Consider the path $\gamma: [0,2\pi]\rightarrow \mathbb{C}$ given by $\gamma(t) = e^{it}$.
Let $f(z) = \frac{1}{z}, z\neq 0$.
I worked out the integral $$\int_\gamma f = \int_{0}^{2\pi} f(\gamma(t))\gamma'(t) dt = 2\pi i$$
However, $f$ is continuous on $f(\gamma([0,2\pi]))$, so I was wondering why this integral is nonzero, since I thought that the integral over a  closed path that takes $[a,b] \rightarrow G$, where $f$ is continous on $G$ and $f$ has a primitive on $G$ should be $0$. What is going wrong here?
 A: Point 1: You have not said what $G$ is; however, $f$ does not have a primitive on the unit circle. $\log(z)$ cannot be continuously well-defined on the unit circle. This is why any definition of $\log(z)$ has branch cuts.
Point 2: Since $\frac1z$ has a singularity at $z=0$, we cannot continuously contract the unit circle to a point in $\mathbb{C}\setminus\{0\}$ without crossing $0$.
A: The following is a fundamental result in complex analysis (see the books of Ahlfors or Rudin).

Theorem. Let $f$ be a holomorphic function on a region $\Omega$; then $f$ has an antiderivative on $\Omega$ if and only if
  $$
\int_\gamma f(z)\,dz=0
$$
  for every closed path in $\Omega$.

(A region is an open and connected subset of the complex plane).
Since the integral you're considering is not zero, it follows that $1/z$ has no antiderivative on a region $\Omega$ that contains a circle centered at $0$, because the integral over this circle is $2\pi i\ne 0$.

It is also well known and basic in complex analysis that the integral of a holomorphic function on a contractible path is zero, so the result follows that a holomorphic function defined on a simply connected region has an antiderivative. So, for instance, $1/z$ does have an antiderivative on a region obtained from the complex plane by removing a ray with origin at $0$ (the main branch cut of the complex logarithm is defined as the antiderivative of $1/z$ over the region obtained by removing the nonpositive real numbers).
On the other hand, simple connectedness is only a sufficient condition; for example, the function $1/z^2$ has an antiderivative on $\mathbb{C}\setminus\{0\}$, which is a non simply connected region.
A: The integral should be zero if the path is contractible. Since $G=\Bbb C\setminus \{0\}$, every path around the origin cannot be deform to a point, so every time you turn around the origin you pay $2\pi i$.
