'Failed to get remote.origin.url

When trying to use gh-pages to deploy a react app I get the following error

...
$ gh-pages -d build
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).
...

The remote is set as origin

$ git remote -v
origin  https://github.com/{user_name}/{repo_name} (fetch)
origin  https://github.com/{user_name}/{repo_name} (push)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source