The common design pattern is clonning and compiling your project in the Docker image build process. In addition, you can configure your image as a Docker Automated Build, which is defined in Docker documentation as:
Automated Builds are a special feature of Docker Hub which allow you
to use Docker Hub's build clusters to automatically create images from
a specified Dockerfile and a GitHub or Bitbucket repo (or "context").
The system will clone your repository and build the image described by
the Dockerfile using the repository as the context. The resulting
automated image will then be uploaded to the Docker Hub registry and
marked as an Automated Build.
The automated build is launch anytime you do a commit (and a push) in the branch of the repo you are pointing. If it is triggered too often maybe you should point to other branch.
Anyway, if you choose to run the git clone when you run a new container, you can configure your Dockerfile with CMD ["my-script"], being my-script any bash script with the code you wish.