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 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