A set of commands to quickly assess the state of a Pull Request.
gh pr status --json number,title,state,conflict,reviewDecision,headRefName,headRepositoryOwner
gh pr checks
gh pr view --comments
Commands to investigate why a specific test is failing.
gh run list --workflow= --branch= --json databaseId,name,status,conclusion
gh run view --log-failed
Commands to detect merge conflicts.
Fetch latest main branch
git fetch origin main
Check if rebase would create conflicts
git rebase --dry-run origin/main
Rebase operations using GIT_EDITOR to prevent interactive prompts.
git checkout
GIT_EDITOR=true git rebase main
If conflicts occur, resolve them manually then use 'git rebase --continue'
git push --force-with-lease
Check current conflict status without interactive input.
git status --porcelain
git diff --name-only --diff-filter=U
List files with unresolved conflicts
git ls-files --unmerged
Check out a pull request branch locally.
gh pr checkout --force
Alternative if gh checkout fails:
git fetch origin pull//head: && git checkout
Determine the correct remote to push to (handles forks).
Get PR metadata to check if it's from a fork
gh pr view --json headRepositoryOwner,headRefName,isCrossRepository
If isCrossRepository is true, it's from a fork
git remote -v
Check if fork remote exists, otherwise add it
git remote add fork https://github.com//.git
Use appropriate remote based on PR source
Monitor PR checks in real-time as they run.
gh pr checks --watch
Continuously monitor check status with automatic updates
For one-time status check: gh pr checks --json state,conclusion,name,detailsUrl
gh run list --pr --json databaseId,status,conclusion
Push operations that handle both origin and fork remotes correctly.
First determine the correct remote (origin or fork)
gh pr view --json headRepositoryOwner,headRefName,isCrossRepository
If isCrossRepository is false, push to origin
git push --force-with-lease origin
If isCrossRepository is true, push to fork remote
git push --force-with-lease fork
If force-with-lease fails, fetch and retry
git fetch
git push --force
Commit operations that work in automated environments.
git add .
git commit -m ""