question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

fresh install, tried running pre-commit clean, no change:

$ pip install pre-commit
Collecting pre-commit
  Using cached pre_commit-0.8.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): aspy.yaml in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): jsonschema in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): pyterminalsize in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): cached-property in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): nodeenv>=0.11.1 in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from pre-commit)
Requirement already satisfied (use --upgrade to upgrade): functools32 in /Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages (from jsonschema->pre-commit)
Installing collected packages: pre-commit
Successfully installed pre-commit-0.8.0
$ pre-commit autoupdate                                          500ms
Updating git://github.com/pre-commit/pre-commit-hooks...An unexpected error has occurred: CalledProcessError: Command: ('/usr/local/bin/git', 'reset', '', '--hard')
Return code: 128
Expected return code: 0
Output: (none)
Errors:
    fatal: ambiguous argument '': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'


Check the log at ~/.pre-commit/pre-commit.log
Traceback (most recent call last):
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/error_handler.py", line 47, in error_handler
    yield
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/main.py", line 155, in main
    return autoupdate(runner)
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/commands/autoupdate.py", line 77, in autoupdate
    new_repo_config = _update_repository(repo_config, runner)
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/commands/autoupdate.py", line 34, in _update_repository
    with cwd(repo.repo_path_getter.repo_path):
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/cached_property.py", line 26, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/store.py", line 47, in repo_path
    return self._store.clone(self._repo, self._sha)
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/store.py", line 122, in clone
    cmd_output('git', 'reset', sha, '--hard', env=no_git_env())
  File "/Users/gretel/.pyenv/versions/2.7.11/envs/taxigirl-2.7.11/lib/python2.7/site-packages/pre_commit/util.py", line 197, in cmd_output
    returncode, cmd, retcode, output=(stdout, stderr),
CalledProcessError: Command: ('/usr/local/bin/git', 'reset', '', '--hard')
Return code: 128
Expected return code: 0
Output: (none)
Errors:
    fatal: ambiguous argument '': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gretelcommented, May 3, 2016

ah, had to be explicit on sha:

---
- repo: git://github.com/pre-commit/pre-commit-hooks
  sha: HEAD
  hooks:
  - id: check-added-large-files
  - id: check-byte-order-marker
  - id: check-docstring-first
  - id: check-case-conflict
  - id: check-json
  - id: check-merge-conflict
  - id: check-symlinks
  - id: check-yaml
  - id: detect-aws-credentials
  - id: detect-private-key
  - id: end-of-file-fixer
  - id: flake8
  - id: pretty-format-json
  - id: requirements-txt-fixer
  - id: trailing-whitespace

works fine now. maybe i was confused by the documentation.

0reactions
gretelcommented, May 3, 2016

let me try:

The value of sha should not be master or HEAD - both will only match the latest version at install time, and prevent subsequent updates. On GitHub, the id of the most recent commit can be looked up easily (i.e. commit/master). Alternatively, setting sha to master and running pre-commit autoupdate before anything else will automatically populate the values of the sha keys in the configuration file:

-   repo: git://github.com/pre-commit/pre-commit-hooks
    sha: master
    hooks:
    -   id: check-added-large-files
    -   id: check-byte-order-marker
    -   id: check-docstring-first
    -   id: check-case-conflict
    -   id: check-json
    -   id: check-merge-conflict
    -   id: check-symlinks
    -   id: check-yaml
    -   id: detect-aws-credentials
    -   id: detect-private-key
    -   id: end-of-file-fixer
    -   id: flake8
    -   id: pretty-format-json
    -   id: requirements-txt-fixer
    -   id: trailing-whitespace
-   repo: git://github.com/pre-commit/mirrors-pylint
    sha: master
    hooks:
    -   id: pylint

which on running pre-commit autoupdate gets to

-   repo: git://github.com/pre-commit/pre-commit-hooks
    sha: 35548254adb636ce52b5574eb1904b8c795b673e
    hooks:
    -   id: check-added-large-files
    -   id: check-byte-order-marker
    -   id: check-docstring-first
    -   id: check-case-conflict
    -   id: check-json
    -   id: check-merge-conflict
    -   id: check-symlinks
    -   id: check-yaml
    -   id: detect-aws-credentials
    -   id: detect-private-key
    -   id: end-of-file-fixer
    -   id: flake8
    -   id: pretty-format-json
    -   id: requirements-txt-fixer
    -   id: trailing-whitespace
-   repo: git://github.com/pre-commit/mirrors-pylint
    sha: 4de6c8dfadef1a271a814561ce05b8bc1c446d22
    hooks:
    -   id: pylint

and is now ready to commit:

$ git commit .pre-commit-config.yaml
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /Users/t.hensel-extern/.pre-commit/patch1462303177.
Check for added large files.................................................................Passed
Check for byte-order marker............................................(no files to check) Skipped
Check docstring is first...............................................(no files to check) Skipped
Check for case conflicts....................................................................Passed
Check JSON.............................................................(no files to check) Skipped
Check for merge conflicts...................................................................Passed
Check for broken symlinks...................................................................Passed
Check Yaml..................................................................................Passed
Detect AWS Credentials......................................................................Passed
Detect Private Key..........................................................................Passed
Fix End of Files............................................................................Passed
Flake8.................................................................(no files to check) Skipped
Pretty format JSON.....................................................(no files to check) Skipped
Fix requirements.txt...................................................(no files to check) Skipped
Trim Trailing Whitespace....................................................................Passed
pylint.................................................................(no files to check) Skipped
[INFO] Restored changes from /Users/gretel/.pre-commit/patch1462303269.
[master 0ffae0b] https://github.com/pre-commit/pre-commit/issues/366 properly have sha set
 1 file changed, 9 insertions(+)
Read more comments on GitHub >

github_iconTop Results From Across the Web

fatal: ambiguous argument 'origin': unknown revision or path ...
I tried. Yes it works. It seems git diff origin is short for git diff master origin/master if the current branch is master...
Read more >
unknown revision or path not in the working tree" mean? : r/git
I was wondering if someone could explain the meaning of fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree ......
Read more >
fatal: ambiguous argument 'master': unknown revision or path ...
Hi Checkout team, I'm trying to checkout both the PR branch & master so diffs can be run on the two and only...
Read more >
fatal: ambiguous argument 'master': unknown revision or path ...
The error looks like you're using a non-existent reference (branch/tag). Try specifying the correct branch and tag using the branch/tag ...
Read more >
My Git Repository is throwing an ambiguous error
... argument 'v0.4.1': unknown re vision or path not in the working tree. npm ERR! git rev-list -n1 v0.4.1: Use '--' to separate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found