How to access repo code in .gitlab-ci.yml scripts?

Hi,
it’s not clear to me how the repo is accessable to my scripts within .gitlab-ci.yml
so a couple of questions to clarify:

  1. what is the difference between setting an image on the top level of the yaml tree and setting it within the stages(build\test jobs etc).
  2. In the deploy job i’m using a docker:latest image so i can push the gitlab images repo, however i’m failing within the docker build when trying to access the git repo files, seems they just aren’t there. why not?
    thanks