bash: git: command not found

2

When I attempt to run git --version (or any git command) in git-bash, I get the following error:

bash: git: command not found

In Windows, I have C:\Program Files\Git\cmd in my Path system variable.

I have created a shortcut on my desktop for git-bash. In its properties, I have removed the --cd-to-home flag from the Target executable, and changed the "Start in" directory to one that is a git repository: D:\my-proj.

When I open git-bash from this shortcut, pwd returns /d/my-proj as expected. However, I still get the bash: git: command not found issue.

Running env from git-bash, I found a couple interesting things:

  1. HOME and HOMEDRIVE are set to /z/ and Z:, respectively.
  2. PATH is set to .:/z//bin:/bin:/usr/bin:/usr/bin/X11:/usr/local/X11R5/bin:/usr/local/bin:/sas/tools/com
  3. ORIGINAL_PATH seems to point to my Windows path variable, but it includes /mingw64/bin:/usr/bin:/z/bin, and does not show a path to Git.

It seems that my git-bash isn't playing nicely with my Windows path variables, but I'm not sure how to set them so I can run Git commands from git-bash. Any advice?

Bucket

Posted 2017-09-12T16:30:03.973

Reputation: 141

1Do you by any chance have files called .profile or .bashrc in your home directory? – gronostaj – 2017-09-12T16:38:42.407

@gronostaj My home directory according to git-bash is /z/, and in there I have both files. Should I look for anything particular in them? – Bucket – 2017-09-12T17:03:38.057

@gronostaj Thank you for your comment. I found that my .profile was setting the PATH variable. – Bucket – 2017-09-12T20:35:09.857

Answers

2

Turns out .profile was setting the PATH variable, preventing it from recognizing git in the Windows path. Commented out this line and it worked.

Bucket

Posted 2017-09-12T16:30:03.973

Reputation: 141