Posts tagged with “pullrequest”

gh pr view can't find PR just created

TLDR;

The solution is git push -u

David.Wei @ /d/git/xemt-core/dfx - [feature/mt-38546-axo] $ git push -u
branch 'feature/mt-38546-axo' set up to track 'origin/feature/mt-38546-axo'.
Everything up-to-date
David.Wei @ /d/git/xemt-core/dfx - [feature/mt-38546-axo] $ gh pr view
MT-38546 Fintrac API| DFX DB changes #1355
Open • David-Wei_euronet wants to merge 6 commits into integration from feature/mt-38546-axo • about 3 days ago
...

vilmibm wrote the following on this issue and it reminds me why I couldn't find the PR:

gh pr view relies on mapping the current locally checked out branch to a remote tracking branch so that the github host can be queried appropriately for PR data; in your example it seems like you're creating PRs without any configured tracking information, making it impossible for gh to open the PR.

To avoid this issue happening in the future, you can run the following command to enable the auto tracking feature.

git config --global push.autoSetupRemote true

If your git version is lower and couldn't upgrade easily, another measure is to create an alias like the following

git config --global alias.p 'push -u origin HEAD'

Then always use git p instead of git push will do the trick.