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.

[bug] Pre-commit hooks errors on first commit

See original GitHub issue

What happened?

git commit -m “Initial commit” [WARNING] Unstaged files detected. [INFO] Stashing unstaged files to /home/userl/.cache/pre-commit/patch1601055885. Trim Trailing Whitespace…Failed

  • hook id: trailing-whitespace
  • exit code: 1
  • files were modified by this hook

Fixing <app>/templates/base.html Fixing utility/install_python_dependencies.sh Fixing <app>/templates/account/password_reset_done.html

[WARNING] Stashed changes conflicted with hook auto-fixes… Rolling back fixes… [INFO] Restored changes from /home/bill/.cache/pre-commit/patch1601055885.

What should’ve happened instead?

Commit to git. This is blocking the commit process. Commit fails and log says file does not match after the trailing whitespace process changed the files.

Additional details

git output: Looking for git in: git Using git 2.28.0 from git

git rev-parse --git-dir Open repository: /home/bill/projects/dfwtaichi git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git check-ignore -v -z --stdin git check-ignore -v -z --stdin git check-ignore -v -z --stdin git check-ignore -v -z --stdin git show --textconv :dfwtaichi/templates/account/password_reset_done.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5 git show --textconv :dfwtaichi/templates/base.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git show --textconv :dfwtaichi/templates/account/password_reset_done.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5 git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git check-ignore -v -z --stdin git show --textconv :utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 git status -z -u git symbolic-ref --short HEAD git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git rev-parse master git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git show --textconv :utility/install_python_dependencies.sh git config --get commit.template git show --textconv :dfwtaichi/templates/base.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git show --textconv :dfwtaichi/templates/account/password_reset_done.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5 git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git symbolic-ref --short HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git show --textconv :config/settings/base.py git config --get commit.template git check-ignore -v -z --stdin git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh fatal: Not a valid object name HEAD git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 git check-ignore -v -z --stdin git branch git rm --cached -r – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh error: the following file has staged content different from both the file and the HEAD: utility/install_python_dependencies.sh (use -f to force removal) git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh fatal: Not a valid object name HEAD git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh fatal: Not a valid object name HEAD git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 git show --textconv :dfwtaichi/templates/account/password_reset_done.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html git cat-file -s c59534afcf4b25c6f0c294d8c3730cf15f09e1d5 git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv :dfwtaichi/templates/base.html git ls-files --stage – /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html git cat-file -s f37f1396ad7ca48c81e111d0b696c0201306d6ec git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git checkout -q – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git checkout -q – /home/bill/projects/dfwtaichi/dfwtaichi/templates/base.html git symbolic-ref --short HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git checkout -q – /home/bill/projects/dfwtaichi/dfwtaichi/templates/account/password_reset_done.html git symbolic-ref --short HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git checkout -q – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git symbolic-ref --short HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git check-ignore -v -z --stdin git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git check-ignore -v -z --stdin git status -z -u git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git symbolic-ref --short HEAD git rev-parse master git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git show --textconv :config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git show --textconv HEAD:utility/install_python_dependencies.sh git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git config --get commit.template git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git symbolic-ref --short HEAD git rev-parse master 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git config --get commit.template git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git status -z -u git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git symbolic-ref --short HEAD git ls-tree -l HEAD – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/utility/install_python_dependencies.sh git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git show --textconv :config/settings/base.py git cat-file -s bdc181a51993964f5225d68b80e08eae70bf0d45 fatal: Not a valid object name HEAD git rev-parse master git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b git show --textconv HEAD:utility/install_python_dependencies.sh 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>…]’ git for-each-ref --sort -committerdate --format %(refname) %(objectname) git remote --verbose git show --textconv :utility/install_python_dependencies.sh git show --textconv :config/settings/base.py git config --get commit.template git ls-files --stage – /home/bill/projects/dfwtaichi/config/settings/base.py git cat-file -s 350adc7e53761a9193d5790d6fc2514c3197c83b

  • Host system configuration:
    • Version of cookiecutter CLI (get it with cookiecutter --version):
    • OS:
    • Python version:
    • Docker versions (if using Docker):
  • Options selected and/or replay file:
Logs:
$ cookiecutter https://github.com/pydanny/cookiecutter-django
project_name [Project Name]: ...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
patoskicommented, Mar 5, 2021

I had the same issue. Per the isort docs, adding the section below to setup.cfg will make isort compatible with black formatting.

[isort]
profile = black
multi_line_output = 3
0reactions
browniebrokecommented, Apr 7, 2021

Just made a change to tidy things up a bit, but the formatting might vary depending on the length your project name. A longer name would wrap lines later, while a shorter one would wrap them earlier. The first commit might fail if some things are reformatted, I think there is no way around that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] Pre-commit hooks errors on first commit #2856 - GitHub
Commit to git. This is blocking the commit process. Commit fails and log says file does not match after the trailing whitespace process...
Read more >
black as pre-commit hook always fails my commits
In my experience there is no need to unstage any files, either just git add the files that black, or other pre-commit hooks,...
Read more >
Fix Your Mistakes, Don't Commit Them! Pre-Commit Git Hook ...
It's time to stop committing broken tests, ugly code, type errors and lint errors to your git repository. With Husky, we can hook...
Read more >
Supported hooks - pre-commit
Checks which PHPUnit executable is available first and then runs it. Preference order is vendor/bin, phpunit and phpunit.phar. php-cs - Run php codesniffer ......
Read more >
git commit failed with git-hook error - Visual Studio Feedback
Git commit in Team Explorer failed when git commit from the command line works fine. The error appeared in an info bar: Your...
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