Repository navigation
gh pr create --fill fails with confusing error: could not compute title or body defaults: fatal: ambiguous argument #5896
Description
Activity
As the same code worked fine, I also observed something interesting, the release notes body contains
--inside and I suppose that it might be a bug inside--fillthat might make it fail when the body contains these characters.Still, when I run from the command line, even with --fill, it did work normally.
Shortly the sentence below should be tell us what happens
could not compute title or body defaults: fatal: ambiguous argument 'origin/main...release/v0.9.0': unknown revision or path not in the working tree.
Maybe there is some caching that makes it fail, as I push the branch right before trying to create the PR. Maybe that is too fast for github and it believes that the branch does not exists?
Should I put a sleep to make it reliable? How long?
@ssbarnea Since it was the
git log origin/main...release/v0.9.0command that failed and we know that arelease/v0.9.0branch for sure exists at this point, I'm inclined to think that it's theorigin/mainbranch that doesn't exist in the context of your action run.Note that
actions/checkoutby default makes a shallow checkout of the exact git ref that your action is running for: https://github.com/ansible/ansible-language-server/actions/runs/2629962634/workflow#L19A shallow checkout means that
origin/*tracking branches will not be available, includingorigin/main.The solution would be to reconfigure your
actions/checkoutstep withfetch-depth: 0(warning: this checkout will be slower, as it fetching everything), or to find an alternative to--fillfor your action.Reacted by Brian Patino and Kelly Sovacool, PhD- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributorand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Jul 13, 2022 - added 2 commits that reference this issue
on Jul 13, 2022 For what it is worth, I believe I was hitting this same thing with my workflow, and indeed, fetching with 'fetch-depth: 0' helped.
Thanks!
Seems like this has been solved with
fetch-depth: 0. Going to close this, please let me know if there is still a bug that needs to be discussed.Reacted by Bernhard HäussnerEncountered this too:
gh pr create --fill -w could not compute title or body defaults: failed to run git: fatal: ambiguous argument 'upstream/main...fix-state-allow_failure-exports': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'(NB: gh is using
upstreamhere because .git/config hasgh-resolved = basefor the upstream remote.)I resolved this issue by first fetching the upstream remote:
git fetch upstreamReacted by MinIO BotThis works for me: #5896 (comment)
👋 @samcoe
I also started getting this out of nowhere after bumping the
ghversion (my home env is managed by nix).I've been using this feature for a long time and it always worked fine before which tells me that something in
ghchanged recently that broke it.The error is:
~/w(pwm/cac-updates|✔) [1] $ gh pr create --fill Warning: 6 uncommitted changes could not compute title or body defaults: failed to run git: fatal: ambiguous argument 'origin/...pwm/cac-updates': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'@pwm What version are you on now and what version did you update from? That will help narrow down what has changed.
Does using
git fetch upstreamfix the issue as others above have reported?I encountered this while testing a modification to a GitHub action workflow... the action worked fine on
main, but then failed when I tested a PR branch.My workflow was trying to create a PR back to
main, and the problem was because when running the existing action onmain, the initialactions/checkoutstep was checking outmain, so everything worked. But on my PR branch that I was testing, theactions/checkoutstep was checking out the PR branch... since it's a shallow clone, it didn't know aboutmain.In my case, because the workflow itself was creating a PR, there was no need to run an additional
git fetch, norwith: fetch-depth: 0instead, I addedwith: ref: "main"to ensure the workflow always checked outmain, even when run from a branch... this way thegh pr createstep was always aware ofmain:- addedpriority-2Affects more than a few users but doesn't prevent core functionsAffects more than a few users but doesn't prevent core functionsand removedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on May 17, 2023 Reopening since this seems to continuously affect people.
I believe that an ultimately correct approach for computing the git log between base and head branches is to ask the GitHub API rather than trying to query it locally.
Ref. #2691
Reacted by Bernhard HäussnerThis issue also effects users in codespaces for probably a reason similar to actions.
- added a commit that references this issue
on Oct 12, 2023 Assuming that you know the base branch of the PR, which is usually the default branch,
instead offetch-depth: 0, a more targeted (faster) workaround is:git fetch origin main gh pr create --fillReacted by ZiadAssuming that you know the base branch of the PR, which is usually the default branch, instead of
fetch-depth: 0, a more target workaround is:git fetch origin main gh pr create --fillThank you, it works for me :)
i've had this multiple times now until i realized that i was required to push my branch first rather than letting
ghask.
i.e.git push --set-upstream [origin] [branch]I have this problem primarily in
git worktrees.I am slowly switching to a setup where I have a single bare clone and
git worktree addfrom it.gh pr createworks without problems,gh pr create --fillcause the error from the OP.Reacted by Jon Campbell- added a commit that references this issue
on Mar 12, 2026
Describe the bug
I got an error below when running
gh pr create --label skip-changelog --fillfrom inside a github action.It is quite weird because I got the impression that the same action worked fine previously so it might be a recent regression.
The effective error comes from git which is called by gh. I checked and the previous command was able to correctly push the code to the new branch, one that has the same nable as the local branch (
release/v0.9.0).Still, gh pr create failed ugly.
Steps to reproduce the behavior
gh version 2.13.0
Expected vs actual behavior
Logs
Code: https://github.com/ansible/ansible-language-server/blob/main/tools/release.sh#L60
Effect: https://github.com/ansible/ansible-language-server/runs/7234603626?check_suite_focus=true