{"meta":{"title":"Warning: \"1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary\"","intro":"If you see this warning, you should update your workflow to follow current best practice.","product":"Security and code quality","breadcrumbs":[{"href":"/en/code-security","title":"Security and code quality"},{"href":"/en/code-security/reference","title":"Reference"},{"href":"/en/code-security/reference/code-scanning","title":"Code scanning"},{"href":"/en/code-security/reference/code-scanning/troubleshoot-analysis-errors","title":"Troubleshoot analysis errors"},{"href":"/en/code-security/reference/code-scanning/troubleshoot-analysis-errors/unnecessary-step-found","title":"Unnecessary step found"}],"documentType":"article"},"body":"# Warning: \"1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary\"\n\nIf you see this warning, you should update your workflow to follow current best practice.\n\n## About this warning\n\n```text\nWarning: 1 issue was detected with this workflow: git checkout HEAD^2 is no longer\nnecessary. Please remove this step as Code Scanning recommends analyzing the merge\ncommit for best results.\n```\n\nIf you're using an old CodeQL workflow you may receive this warning from the \"Initialize CodeQL\" action.\n\n## Confirm the cause of the problem\n\nCheck for the following lines from the CodeQL workflow. These lines were included in the `steps` section of the `Analyze` job in initial versions of the CodeQL workflow.\n\n```yaml\n        with:\n          # We must fetch at least the immediate parents so that if this is\n          # a pull request then we can checkout the head.\n          fetch-depth: 2\n\n      # If this run was triggered by a pull request event, then checkout\n      # the head of the pull request instead of the merge commit.\n      - run: git checkout HEAD^2\n        if: ${{ github.event_name == 'pull_request' }}\n```\n\n## Fixing the problem\n\nRemove the lines from the CodeQL workflow. The revised `steps` section of the workflow should now look like this:\n\n```yaml\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      # Initializes the CodeQL tools for scanning.\n      - name: Initialize CodeQL\n        uses: github/codeql-action/init@v4\n\n      # ...\n```"}