简体   繁体   English

无法从Windows中的Git bash运行Git自定义命令

[英]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. 我创建了一个小的可执行文件(git-test),并将其放置在C:\\Program Files\\Git\\usr\\bin路径下。

I have also added the above path in the Path environment variable. 我还在Path环境变量中添加了上述路径。 When I run git test on bash it gives me below error. 当我在bash上运行git test时,出现以下错误。

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. 创建文件时,我忘了将#!/bin/sh作为第一行。 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-test文件中添加这一行时,我能够使用git test命令从git bash运行该文件。

Git does not have a test command. Git没有test命令。

If you want to set your own git command you should set git alias . 如果要设置自己的git命令,则应设置git alias
Gti aliases can be simple commands. Gti别名可以是简单的命令。 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. 看一下l别名。 Its alias for a bash script in unix. UNIX中bash脚本的别名。

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 . git test不是git知道的命令,因为它通过提示运行git --help列出的可用命令来告诉您。

To execute that command, type: git-test because that's the full command name. 要执行该命令,请键入: git-test因为这是完整的命令名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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