Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

In a `pull_request` workflow, `git log -1` shows `Merge 4f1c2d3 into 9a8b7c6` and `git rev-parse HEAD` differs from the PR's head SHA.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → For pull_request events, actions/checkout checks out refs/pull/<n>/merge, a temporary merge of the PR head into the base. That is intended (it tests the merge result), but it surprises tools that tag images or report status by HEAD.

Diagnose →

echo "$GITHUB_SHA"                                     # merge commit SHA
echo "${{ github.event.pull_request.head.sha }}"       # real PR head

Fix → If you need the PR head itself:

- uses: actions/checkout@v4
  with:
    ref: ${{ github.event.pull_request.head.sha }}

Use github.event.pull_request.head.sha for image tags and commit statuses.

Prevent → Decide deliberately per workflow: merge ref for testing, head SHA for reporting.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues