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

Two concurrent workflow runs both try to push a changelog commit; one fails with `! [rejected] main -> main (fetch first)`.

AdvancedTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → Runs triggered close together each checked out an older main, committed, and raced to push. The loser's commit is based on a stale parent.

Diagnose → Compare run start times in the Actions tab and git log origin/main -3 after the failure.

Fix → Serialize the jobs and retry with rebase:

concurrency:
  group: release-main
  cancel-in-progress: false
steps:
  - run: |
      for i in 1 2 3; do
        git pull --rebase origin main && git push origin HEAD:main && break
        sleep $((i * 5))
      done

Prevent → Avoid bots committing to main for every merge; generate changelogs at release time, or have a single release workflow guarded by a concurrency group.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues