Repository navigation
pr create push detection should work in repositories that are tracking only a single branch #2979
Description
Activity
Thanks for reporting!
- After you push the branch, is the remote-tracking branch created? Check with
cat .git/refs/remotes/origin/<branch-name> - Do you have multiple git remotes in this repository?
- Is your gh up-to-date?
- After you push the branch, is the remote-tracking branch created? Check with
- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on Feb 16, 2021 @mislav OK, I set up this workflow as an MVCE. The run fails on your
catcommand, so apparently the remote tracking branch is not getting created. That is not how I understand Git to work; do you know how to fix this?EDIT: OK, I fixed it. The problem was due to the use of
--depth 1, and adding--no-single-branchto thegit clonecommand got rid of the error.- removedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on Feb 17, 2021 @jwodder Thank you for checking! I will reopen this and keep it filed as a bug report because I believe that ideally,
pr createshould work even in repositories that were cloned with--depth 1or are tracking just a single branch.Reacted by Dan Loman, Miloš Lajtman, Julien Carsique, Kenneth, Pavlo Shevchenko and Kodai Matsumoto- changed the title
[-]`gh pr create` thinks branch hasn't been pushed to repository even though it has[/-][+]`pr create` push detection should work in repositories that are tracking only a single branch[/+]on Feb 17, 2021 - addedpriority-3Affects a small number of users or is largely cosmeticAffects a small number of users or is largely cosmetic
on Feb 17, 2021 I just try to use the --depth 1 when creating a PR right after. It still fails :( I think it's a really important thing as some repo can be huge and take a few minutes to clone
- added a commit that references this issue
on Jun 2, 2022 Perhaps worth mentioning, Since git release 1.8.3.2, using
--depthignores remote branches unless--no-single-branchis also specified.
I have a shell script that is run as part of a GitHub Actions workflow that, on occasion, clones a repository, creates, commits to, and pushes a branch, and then creates (or at least tries to) a pull request for the branch using
gh pr create. However,ghis failing with "aborted: you must first push the current branch to a remote, or use the --head flag" despite the fact that the command immediately before it is "git push -u origin "$branch_name" (tried with & without the-uoption).https://x-access-token:[email protected]/$OWNER/$REPO, where the same token is also set as the$GITHUB_TOKENenvironment variable.--headoption is used.