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

39,846

Solution 1

The error looks like you're using a non-existent reference (branch/tag). Try specifying the correct branch and tag using the branch/tag options. You can also use the commit hash directly using ref option.

Also ensure that your git URL is correct (your code does not contain the xxx.git part).

Solution 2

I recently ran into the same error. In my case, I had rebased a branch and was attempting to push to the remote. One of the pulled commits had changed the structure of a few directories, and git refused to push after the rebase, throwing:

fatal: ambiguous argument 'path/to/scripts': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Cannot open directory /absolute/path/to/scripts: No such file or directory
error: failed to push some refs to 'git@host:repo'

I tore apart all of my git configs and could not find the cause of this anywhere. The culprit turned out to be a pre-push git hook, left over from some previous config we used to use, which included some operations on the now-defunct directory.

While this clearly wasn't the cause of the OP's issue, thought I'd post this here in case someone else gets bitten. Beware the git hooks...

Share:
39,846

Related videos on Youtube

pandey
Author by

pandey

Updated on September 18, 2022

Comments

  • pandey
    pandey over 1 year

    when I modified one of my cookbook that I tried to add a cookbook dependency in berks file

    cookbook name, '=0.1.0', git: 'ssh://url:xxx/cookbook', tag: '0.0.1'
    

    and then tried to converge it which throws an error

    'fatal: ambiguous argument 'master': unknown revision or path not in the working tree.use '--' to separate paths from revisions, like this:git <command> [<revision>...] -- [<file>...]'on test
    

    I don't have much clue to explain even..but I can post my explanation as we go. I appreciate your help thank you

  • pandey
    pandey almost 7 years
    yes you are right. I used undefined tag so I received that error. giving a correct tag helped to solve this. Thanks @grumpyops