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.
Check PR mergeable status
gh pr view --json mergeable,mergeStateStatus
If mergeable is false or mergeStateStatus is CONFLICTING, delegate to merge-resolver
Delegate merge conflict resolution to the merge-resolver mode.
When conflicts are detected, create a new task for merge-resolver
merge-resolver
#
]]>
Wait for merge-resolver to complete before continuing with other fixes
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 while respecting .gitignore.
Review what files have been modified
git status --porcelain
Add only tracked files that were modified (respects .gitignore)
git add -u
If you need to add specific new files, list them explicitly
git add
git commit -m ""
Safely stage files for commit while avoiding temporary files and respecting .gitignore.
First, check what files are currently modified or untracked
git status --porcelain
Review the output to identify files that should NOT be committed:
- Files starting with . (hidden files like .DS_Store, .swp)
- Build artifacts (dist/, build/, *.pyc, *.o)
- IDE files (.idea/, .vscode/, *.iml)
- Temporary files (*.tmp, *.temp, *~)
Option 1: Stage only modified tracked files (safest)
git add -u
Option 2: Stage specific files by path
git add src/file1.ts src/file2.ts
Option 3: Use pathspec to add files matching a pattern
git add '*.ts' '*.tsx' --
Option 4: Interactive staging to review each change
git add -p
Always verify what's staged before committing
git diff --cached --name-only