Analysing different branches of the same Git repository with CodeScene

    Each CodeScene project runs its analysis against a specific branch. Typically, this is your main development branch (e.g. `main`, `master`, `develop`). However, sometimes you want to analyze another long-lived branch, perhaps a release branch. This document explains how to do that.


    To analyze the same repository but a different branch, you need to create one more CodeScene project. Make sure the new project uses a separate local copy of your Git repo, and point it to the branch of interest in the project configuration.


    Here are the steps:

    1. Create a new project.
    2. Point the new project to the same Git repository (i.e. same remote URL). Do not use the clone feature as it will end up having a shared repository so that changing the branch in one project also flips it for the other project -- that's not what you want.

      If you run CodeScene via the Docker image, then everything works out of the box. Should you run the JAR distribution instead, then you need to consider the following:

       - If you have CODESCENE_CLONED_REPOSITORIES_ROOT configured (the recommended default), then CodeScene will automatically clone a new local copy, and everything will work as expected

       - If you manually have to specify a local path for cloning the repo, then make sure to use a different path than the other project. That way, you guarantee a separate copy of the repo.

    3. Once the project is created, select the new branch from the drop-down in the project configuration:


    Additional hints on project setup
    :

    • The typical setup is to have one project which analyses your main development branch.
    • Short-lived feature branches are analyzed automatically via CodeScene's code review of Pull Requests: Integrate CodeScene with Pull Requests