简体   繁体   中英

Not able to run the Git custom commands from Git bash in windows

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.

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 .

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.

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM