首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git-log错误:模糊参数“主”

git-log错误:模糊参数“主”
EN

Stack Overflow用户
提问于 2015-08-21 15:46:08
回答 3查看 1.8K关注 0票数 3

我正在运行一个存储在git中的java项目的maven构建。当发布计划运行在构建服务器(使用竹)上时,它发出以下git命令:

代码语言:javascript
复制
git log -n1 --date-order master

但是收到以下错误:

代码语言:javascript
复制
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.

当然,我有一个主分支,当我拉下repo并在本地运行命令时,它工作得很好。我的猜测是构建服务器上有不同的配置,但是我不知道该寻找什么。我希望你们中的一个专家能有一些洞察力。

作为参考,下面是我从maven构建中获得的实际错误日志。它发生在buildnumber-maven-plugin执行过程中:

代码语言:javascript
复制
build   19-Aug-2015 15:10:28    [INFO] [INFO] --- buildnumber-maven-plugin:1.2:create (default) @ my-rest-project ---
build   19-Aug-2015 15:10:28    [INFO] [INFO] Verifying there are no local modifications ...
build   19-Aug-2015 15:10:28    [INFO] [INFO] Executing: /bin/sh -c cd /usr/local/atlassian/bamboo-home/xml-data/build-dir/MKL-RR-JOB1/target/checkout && git status --porcelain
build   19-Aug-2015 15:10:28    [INFO] [INFO] Working directory: /usr/local/atlassian/bamboo-home/xml-data/build-dir/MKL-RR-JOB1/target/checkout
build   19-Aug-2015 15:10:28    [INFO] [INFO] Executing: /bin/sh -c cd /usr/local/atlassian/bamboo-home/xml-data/build-dir/MKL-RR-JOB1/target/checkout && git log -n1 --date-order master
build   19-Aug-2015 15:10:28    [INFO] [INFO] Working directory: /usr/local/atlassian/bamboo-home/xml-data/build-dir/MKL-RR-JOB1/target/checkout
build   19-Aug-2015 15:10:28    [INFO] [ERROR] Provider message:
build   19-Aug-2015 15:10:28    [INFO] [ERROR] The git-log command failed.
build   19-Aug-2015 15:10:28    [INFO] [ERROR] Command output:
build   19-Aug-2015 15:10:28    [INFO] [ERROR] fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
build   19-Aug-2015 15:10:28    [INFO] Use '--' to separate paths from revisions, like this:
build   19-Aug-2015 15:10:28    [INFO] 'git <command> [<revision>...] -- [<file>...]'
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-09-17 21:50:30

它在运行maven版本插件2.2和更低版本时工作。

当发布插件在2.3-2.5版本之间(2.5是本文撰写的最新版本)时,maven发布插件和maven-buildnumber-plugin之间存在某种冲突。

我不知道错误的确切原因是什么,但是日志显示发布插件在这些版本中执行一个额外的git命令,它不知怎么会导致紧接着运行的buildnumber插件失败。

具体来说,它运行git ls-remote ssh://git@reponame.git,并在临时目录中运行它,而不是运行所有其他git命令所在的目录。我不确定那是马文小故障还是竹子故障。无论如何,我现在知道该怎么做了。

更新:在遇到另一个迫使我将maven发布插件升级到2.5的竹/maven发布/git问题后,我确定唯一的解决办法是放弃构建号插件。最终,导致这个问题的是构建号插件,这对我的工作流程来说并不重要。

票数 2
EN

Stack Overflow用户

发布于 2017-04-14 13:53:55

致命的:模糊的论证‘主人’:未知的修订或路径不在工作树中。

这似乎是一些git版本问题,运行在CI框上的git命令(或包)与buildnumer-maven-plugin生成的命令不兼容。在我的Mac电脑上对我来说很管用。

在我们的CI框上修正的是将doUpdate更改为false。我们已经将doCheck设置为false,所以现在我们的配置如下:

代码语言:javascript
复制
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    ...
    <configuration>
        <doCheck>false</doCheck>
        <doUpdate>false</doUpdate>  <!-- changed this from true -->
    </configuration>
</plugin>

这导致buildnumber-maven-plugin发出以下git命令,该命令似乎在任何地方都运行良好:

代码语言:javascript
复制
[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ parent ---
[INFO] Executing: /bin/sh -c cd '/build/parent' && 'git' 'rev-parse' '--verify' 'HEAD'
票数 3
EN

Stack Overflow用户

发布于 2015-08-21 17:31:03

构建服务器可能只是从您的而不是从git存储库中得到的文件。在许多构建服务器中,这是一个非常常见的设置,您可能需要检查是否是这样的。

许多构建服务器还提供了选项,让回购检查以及。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32144454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档