git clone/checkout code was mostly the same copied over and over. Move code to a single common function Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>