Planky Planky - 1 year ago 132
Git Question

git-log error: ambiguous argument 'master'

I'm running a maven build of a java project that is stored in a git repo. When the release plan runs on a build server (using Bamboo) it issues the following git command:

git log -n1 --date-order master

but recieves the following error:

fatal: ambiguous argument 'master': unknown revision or path not in the working tree.

I do, of course, have a master branch and when I pull down the repo and run the command locally it works fine. My guess is that there's different configuration on the build server but I'm at a loss for what to look for. I'm hoping one of you git experts will have some insight.

For reference, here is the actual error log I'm getting from the maven build. It occurs during the buildnumber-maven-plugin execution:

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>...]'

Answer Source

It works when running the maven-release-plugin 2.2 and lower.

It turns out that there is some kind of conflict between the maven-release-plugin and the maven-buildnumber-plugin when the release plugin is between versions 2.3-2.5 (2.5 is the latest as of this writing).

I'm not sure what the cause of the error is exactly, but the logs show the release-plugin doing an extra git command in those versions and it somehow causes the buildnumber plugin which runs right after it to fail.

Specifically, it runs git ls-remote ssh://git@reponame.git and runs it in a temp directory rather than the directory that all the other git commands run in. I'm not sure if that's a Maven glitch or a Bamboo one. In any case, I know how to work around it now.

UPDATE: After running into another bamboo/maven-release/git issue that forced me to upgrade the maven-release-plugin to 2.5, I determined that the only way around all of this was to drop the buildnumber plugin. Ultimately it was the buildnumber plugin that was causing the issue and it wasn't important to my workflow after all.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download