When building a branch (let’s say branch1
), the Checkout code step will do this after cloning the git repository:
git reset --hard "$CIRCLE_SHA1"
git checkout -q -B "$CIRCLE_BRANCH"
git reset --hard "$CIRCLE_SHA1"
This will make the local reference of master
point to the HEAD of branch1
before checking out branch1
.
The first command should probably be simply git reset --hard
or a git clean -fd
(just to ensure that the checkout following it will succeed).
I’ve confirmed the problem with the following build. When building a branch, master is pointing to that same branch:
https://circleci.com/gh/dbmeneses/test_git/5
It creates problems when running SonarCloud analysis, as the scanner will be tricked into thinking that there are no changes in the current branch compared to master: