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.

prepre-commit-msg git hook breaks IDE

See original GitHub issue


While integrating this tool I noticed that my IDE started to misbehave when it performed git operations.

The example in the docs offers the following approach, which assumes /dev/tty is always available:

exec < /dev/tty && git cz --hook # <-- This fails when "not a tty"

The below uses a short-circuit to exit with an exit code of 0 in case tty is not available.

exec < /dev/tty && git cz --hook || true

Using the above solved a case where my IDE got killed during a rebase
But I suspect that anything that interacts with git is susceptible to this pitfall.

Let me know if you agree, and i’ll work on a PR.


Found a case in point:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

micaleviskcommented, Feb 17, 2021

I’m still getting this error with Visual Studio Code in my Ubuntu 😕

This is what I’m using to fix that instead of just exec < /dev/tty && git cz --hook --hook || true:

( exec < /dev/tty && git cz --hook --hook ) || true 2> /dev/null
eliraneliassycommented, Aug 12, 2019

@eladchen - Thanks, just ran to the same issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

git commit failed with git-hook error - Visual Studio Feedback
Client-side hooks seems like a basic git feature that should just work. And I think it worked at one time in Visual Studio...
Read more >
Git Hooks - Git SCM
The first four hooks have to do with the committing process. The pre-commit hook is run first, before you even type in a...
Read more >
Fixing mac/windows new lines with git pre-commit hook?
For Windows machines use git config --global core.autocrlf true. with this settings git will convert all \r\n line endings to \n before every...
Read more >
Pre-commit: Don't git hooked! - Thoughtworks
Git hooks are a feature of git that enable custom scripts to be triggered on certain events during the execution of a git...
Read more >
Show the output of the git hook scripts : IDEA-82777 - YouTrack
IDEA-154053 Git pre-push hooks not propagating error messages to IDE ... IDEA-153912 Commit failed with error loses formatting (line breaks and angle ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found