Failed to get remote.origin.url error after upgrading to git v2.35.2
Dae314 opened this issue · 2 comments
Under git version 2.35.1.windows.2, running npx gh-pages -d public
works as expected.
Upgrading to any git version 2.35.2 or newer results in the following error:
Failed to get remote.origin.url (task must either be run in a git repository with a configured origin remote or must be configured with the "repo" option).
Git v2.35.2 includes a fix for some security issues:
https://github.blog/2022-04-12-git-security-vulnerability-announced/
Potential fixes are found in:
gitextensions/gitextensions#9954
However, even using the extreme command:
git config --global --add safe.directory *
Does not resolve the error for me.
Unsure what permissions are required for gh-pages to function with the git v2.35.2 changes. Please advise.
I encountered this issue in Powershell running in the Windows terminal. Strangely it doesn't occur in the VSCode integrated terminal.
It doesn't seem to like the .git
on the end of the repo url. As a workaround, try setting the -r
flag to the remote url without the trailing .git
PS repo> git config --get remote.origin.url
https://github.com/bm9k/repo.git
PS repo> pnpm exec gh-pages -r https://github.com/bm9k/repo.git -d dist
Failed to get remote.origin.url (task must either be run in a git repository with a configured
origin remote or must be configured with the "repo" option).
PS repo> pnpm exec gh-pages -r https://github.com/bm9k/repo -d dist
Published
PS repo> git --version
git version 2.37.1.windows.1
(pnpm exec ...
is equivalent to npx ...
)
I tested bm9k's solution using git v2.37.1.windows.1
, and it worked even from the VSCode terminal!
I'll update my npm script to include the -r repo flag. Not sure what's causing this bug in the tool, but ty for the workaround!
FYI, I had been doing all of my testing from the VSCode terminal even for the original incident description.