windows - SourceTree 自定义操作不起作用,但通过 Git 终端窗口起作用

标签 windows atlassian-sourcetree git

我正在尝试设置 Source Tree 自定义 Git 操作以提取和压缩文件以从选定的提交到 HEAD 进行部署,使用 --diff-filter 排除已删除的文件。

archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR $SHA)

Source Tree custom action screenshot

问题是这个 Git 命令在 Git 终端窗口中完美运行,没有错误,但是当我尝试在源代码树中使用它时,我得到了这个错误。

git archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR fbf360c607b01fc8c504c9fcf98114eb4bc1896c) 错误:未知选项名称

Source Tree custom action error message screenshot

我试图找出这个问题的问题所在,但没有成功。我想知道是否有人在 Source Tree 中遇到过这个或类似的问题,因为它对我来说像是一个错误。

最佳答案

$(...) 是 bash commands substitution ,它在内部运行命令并将其输出插入命令行。 SourceTree 不使用 bash 来调用命令(它是 Windows,不是吗?),并且您的命令不会被替换。

您应该改为将命令放在脚本中,大致如下:

------c:..\script.sh-----

#!/bin/sh
git archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR "$1")

并设置从源代码树中调用它:
要运行的脚本:[ ...\bash.exe ]
参数:[ -c c:..\script.sh $SHA1 ]

关于windows - SourceTree 自定义操作不起作用,但通过 Git 终端窗口起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36212080/

相关文章:

c++ - 在windows下用c++列出目录

python - 为什么 tkinter 按钮的高度选项在 OSX 和 Windows 上的行为不同?

git - 从 SourceTree 创建一个文件的 git diff

git - Jenkins - 提升构建和 Git

git - 交互式 git rebase

windows - 我可以尝试通过特定适配器 ping 网站吗?

windows - 使用 Windows 命令行在本地运行 jmeter .jmx 测试给出非法参数异常

git - 推送到远程 Git 存储库时出错

git - 如何在 SourceTree 本地 checkout fork 的 pull 请求?

git - 如何从 git 存储库中提取源文件?