Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 有没有办法向git别名添加多个步骤?_Windows_Bash_Powershell_Git Bash_Windows Subsystem For Linux - Fatal编程技术网

Windows 有没有办法向git别名添加多个步骤?

Windows 有没有办法向git别名添加多个步骤?,windows,bash,powershell,git-bash,windows-subsystem-for-linux,Windows,Bash,Powershell,Git Bash,Windows Subsystem For Linux,我将创建一个别名来执行以下操作: 我已经将它添加到我的git bash.bash_配置文件中,但我想看看是否有办法将其添加为别名,这样我就不必使用git bash了 Git finish将推送到当前分支,例如gf“提交消息” 您可以创建一个“Git子命令”。此可执行文件的名称必须采用以下格式:Git-{{name}eg:Git-acommit。此文件必须位于$PATH中列出的目录之一,您现在可以执行git acommit,git将在您的$PATH中搜索它 要在别名中使用它,只需运行git con

我将创建一个别名来执行以下操作:

我已经将它添加到我的git bash.bash_配置文件中,但我想看看是否有办法将其添加为别名,这样我就不必使用git bash了

Git finish将推送到当前分支,例如gf“提交消息” 您可以创建一个“Git子命令”。此可执行文件的名称必须采用以下格式:
Git-{{name}
eg:
Git-acommit
。此文件必须位于
$PATH
中列出的目录之一,您现在可以执行
git acommit
,git将在您的
$PATH
中搜索它

要在别名中使用它,只需运行
git config--global alias.gf acommit
,就完成了请注意:别名步骤是不必要的,因为您可以根据需要命名文件,因此您也可以将其命名为
git gf
,而不是
git acommit

但是如果不创建单独的文件,就不可能在git别名中堆叠命令

或者,您可以使用创建执行函数或多个命令的别名。 有关示例,请查看该部分

gf() {                                                                                                                           
 CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"                                                                      
 git add . && git commit -m "$1" && git push origin "$CURRENT_BRANCH"                                            
}                                                                                                                                                                                                                                               # Git merge                                                                                                             # Eg. gm branch-name                                                                                                    
gm() {                                                                                                                           
  git merge "$1"                                                                                                  
}                                                                                                                                                                                                                                               # Git checkout                                                                                                          # Eg. gc branch-name                                                                                                    
gc(){                                                                                                                            
 git checkout "$1" && gp                                                                                         
}