Finding a group with a prescribed normal subgroup and quotient group While analyzing some exact sequences of group homomorphisms, I went across the problem below. It seems fairly simple, so there are probably well-known theorems that one can use to get the answer quickly.
The problem:
I am looking for a group $G$ that has a normal subgroup $\mathbb{Z}$, such that the quotient group $G/\mathbb{Z}\cong\mathbb{Z}_2$. The goal is to find all $G$ with such a property.
There are the two obvious Abelian solutions: First, $G \cong \mathbb{Z}$ (where the subgroup corresponds to even integers), and second, $G \cong \mathbb{Z}\oplus \mathbb{Z}_2$. However, could there be additional non-Abelian solutions? 
A related problem:
How does the result change if the quotient group is $G/\mathbb{Z}\cong\mathbb{Z}$. Are there solutions other than the obvious  $G\cong\mathbb{Z}\oplus\mathbb{Z}$? 
 A: Abelian case
There's a tool to work with group extensions, at least in the abelian context. It is called the Ext functor. Generally non-equivalent (which is a bit weaker then non-isomorphic, non-equivalent extensions can be isomorphic) extensions of $N$ via $Q$ correspond to elements of
$$\text{Ext}^1_{\mathbb{Z}}(Q, N)$$
The direct sum $Q\oplus N$ always corresponds to the trivial element in $\text{Ext}^1(Q, N)$.
Now if $Q$ is projective (as a $\mathbb{Z}$-module, i.e. free abelian group) then $\text{Ext}^1(Q, N)=0$ which implies that the answer to the question

Let $G$ be such that there is $N\subseteq G$ with $N\simeq\mathbb{Z}$ and $G/N\simeq\mathbb{Z}$. Are there solutions other than the obvious $G\simeq\mathbb{Z}\oplus\mathbb{Z}$?

is no.
Now lets consider $Q=\mathbb{Z}_2$ and $N=\mathbb{Z}$.

There are the two obvious Abelian solutions

Yes, this follows because
$$\text{Ext}^1(\mathbb{Z}_2,\mathbb{Z})\simeq\mathbb{Z}_2$$
(which you can calculate from general properties of the Ext functor). Therefore there are 2 non-equivalent extensions and thus at most 2 non-isomorphic. You found two non-isomorphic solutions which completes the classification.
Trivial non-abelian (i.e. semidirect product)
Now non-abelian case is generally hard. But luckily when we work with $\mathbb{Z}$ and $\mathbb{Z}_p$ (for prime $p$) everything becomes easier.
The trivial non-abelian example is the semidirect product $N\rtimes Q$. I call it "trivial" because it corresponds to a short exact sequence $1\to N\to G\to Q\to 1$ that splits. The reverse also holds: if such sequence splits then $G$ is a semidirect product of $N$ and $Q$.
Since we are working in non-abelian case then by "semidirect product" I'm going to understand "non-abelian semidirect product" from now on. Note that the only abelian semidirect product is the direct product.
For $Q=\mathbb{Z}_2$ and $N=\mathbb{Z}$ this gives the infinite dihedral group. There are no other possibilities of semidirect product of $N$ and $Q$ because there's only one non-trivial homomorphism $Q\to\text{Aut}(N)$. Note that $\text{Aut}(\mathbb{Z})\simeq\mathbb{Z}_2$.
For $Q=N=\mathbb{Z}$ we have that the only non-trivial semidirect product $Q\rtimes N$ is actually $\mathbb{Z}\times\mathbb{Z}$ with group multiplication given by
$$(a,b)(c,d)=(a+ (-1)^bc, b+d)$$
Non-trivial non-abelian?
There are none. Thanks to @Derek Holt for hints to solve that case.
Indeed, the case $N=Q=\mathbb{Z}$ is quite simple. Every short exact sequence of the form
$$1\to N\to G\to\mathbb{Z}\to 1$$
has to split because $\mathbb{Z}$ is not only free-abelian but also free among all groups. Therefore if $f:G\to\mathbb{Z}$ is an epimorphism and $f(g)=1$ for some $g\in G$, then $h:\mathbb{Z}\to G$ given by $h(1)=g$ is the partial inverse.
The case $N=\mathbb{Z}$ and $Q=\mathbb{Z}_p$ (for prime $p$) is a bit more difficult. We will show that every such extension has to split as well. Or equivalently that $G$ is a semidirect product of $N$ and $Q$. 
So let $g\in G$ such that $g\not\in N$ (for simplicity I assume that $N\subseteq G$). Define by $H=\langle g\rangle$. Since $G/N\simeq\mathbb{Z}_p$ then $\{N, H\}$ generate entire $G$. Since $N$ is normal then $G=NH$. And since $G/N\simeq\mathbb{Z}_p$ then $g^p\in N$. Let $e\in G$ be the neutral element. Now we have two cases:


*

*$g^p=e$. Then $N\cap H=\{e\}$ (the assumption about $p$ being prime kicks in here) and therefore (since $G=NH$) $G$ is the semidirect product of $N$ and $H$.

*$g^p\neq e$. In that case consider the automorphism $\varphi_g:G\to G$ given by $\varphi_g(x)=gxg^{-1}$. Since $N$ is normal then we can restrict it to $\varphi_g:N\to N$. Since $N\simeq\mathbb{Z}$ then $N$ has only two automorphism: the identity and the inverse. But both cases are impossible. Indeed, if $\varphi_g(x)=x$ then $gxg^{-1}=x$ and thus $gx=xg$ which contradicts $G$ being non-abelian. If on the other hand $\varphi_g(x)=x^{-1}$ then $gg^pg^{-1}=g^{-p}$ and thus $g^p=g^{-p}$, i.e. $g^p$ is an element of order at most $2$ in $N$. This is impossible because $N\simeq\mathbb{Z}$ and the only finite-order element in $\mathbb{Z}$ is the neutral element. But we assumed that $g^p\neq e$.


This proves that there are no non-split extensions of the form
$$1\to \mathbb{Z}\to G\to\mathbb{Z}_p\to 1$$
