1

I have created a small executable file (git-test) and placed it under C:\Program Files\Git\usr\bin path.

I have also added the above path in the Path environment variable. When I run git test on bash it gives me below error.

git: 'test' is not a git command. See 'git --help'

Is there anything I am missing here or anywhere I need to paste the file.

2
  • And if you add the '.exe' extension?
    – Philippe
    Feb 13, 2016 at 22:18
  • 1
    There is no '.exe' file here. I have just create a shell script file with the name pattern as git-<custom-name> and tried to access it using git bash. (like the way git flow command works)
    – nak
    Feb 14, 2016 at 5:13

3 Answers 3

5

My bad!!! While creating the file I forgot to mention the #!/bin/sh as first line. When I added this line in my git-test file I was able to run the file from git bash using the command git test.

2
  • 1
    I came back to give you this advice and already found it ;) Well done! And you could put your file anywhere in the PATH not specially in the git folder.
    – Philippe
    Feb 14, 2016 at 11:02
  • Thanks @Philippe! I will also try putting my file in different folders.
    – nak
    Feb 14, 2016 at 11:14
0

Git does not have a test command.

If you want to set your own git command you should set git alias.
Gti aliases can be simple commands. multiple commands and even executing a script file.

For example you can see here few simple aliases + some complex ones.
Take a look on the l alias. Its alias for a bash script in unix.

In your case create an alias for your test script in the same way.

enter image description here

-2

git test is not a command that git knows, as it's telling you by hinting at the available commands listed by running git --help.

To execute that command, type: git-test because that's the full command name.

1
  • 1
    I am trying to figure out a way how custom commands in git works. The way where you create a shell script file by the name git-<custom-name> and call from git bash with command git custom-name. I took the example of git flow commands, where I am having all git flow files in C:\Program Files\Git\usr\bin (e.g. git-flow) and I can execute the script from git bash using the command git flow.
    – nak
    Feb 14, 2016 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.