0

I want to push a project I created to Heroku from Git. I'm running windows and have the Git Bash shell installed as well as the Heroku CLI. Running this from Git Bash shows my Git version:

$ git --version
git version 2.14.1.windows.1

However, when I try from that same Git Bash shell to create my application on Heroku as a remote Git repo, I get an error:

$ heroku create
bash: heroku: command not found

So instead I created my application on Heroku from a regular windows cmd terminal and that worked (i.e., when I log into heroku I see the remote repo). But when I try to do a git push from the windows cmd terminal it does not recognize git:

C:\myapp>git push heroku master
'git' is not recognized as an internal or external command,
operable program or batch file.

Whereas when I try to do a git push from the git bash shell, I get this error indicating perhaps it doesn't know what to make of heroku:

$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

So it seems my regular windows cmd terminal recognizes heroku, but my Git bash terminal does not. How do I configure Git bash to recognize the Heroku command?

Note: When I do a env | grep path from the Git bash shell the results do include my C:/Program Files/Heroku/bin directory, so Git is aware of my Heroku path.

Woodchuck
  • 3,869
  • 2
  • 39
  • 70

3 Answers3

2

Your problem is not that git would not push to heroku, but that you actually haven't installed git on your system, as the message you posted suggests.

'git' is not recognized as an internal or external command, operable program or batch file.

At heroku's documentation there is a whole article about pushing to git, if you experience further problems after installing git, you might find a solution there.

nyronium
  • 1,258
  • 2
  • 11
  • 25
0

Found a solution! It required the following 3 steps/considerations:

  • First, I followed john g's answer here, which is to close Git Bash and login to Heroku via a windows cmd terminal, then use Git Bash as per normal.
  • Second, when issuing a heroku command from Git Bash on Windows, include the extension, as described here. I.e., issue heroku.cmd create (instead of just heroku create).
  • Third, apparently the git push heroku master command must be issued from the same Git Bash terminal where you just issued heroku.cmd create. When I had issued it from a separate terminal I got an error saying "'heroku' does not appear to be a git repository".
Woodchuck
  • 3,869
  • 2
  • 39
  • 70
0

I'm posting this, in hopes that it may help others and save them the same trouble I had. This was driving me mad and I tried every solution I could manage to find on the issue. Spent several hours trying to trouble-shoot it. What it actually ended up being was a conflict with my internet security, specifically Comodo Internet Security Premium 10. I received no warning, it just automatically added it to a blocked list on first execution. If you are running internet security software, especially on a Windows machine, this very well could be your issue. Remove the command file found at C:\Users\YOUR_USER_NAME\AppData\Local\heroku\client\bin\heroku.cmd from any block list, as well as any other executables from heroku that may be on the list.

RichardB
  • 3
  • 3