Git push failed due to husky pre-push on sourcetree

krishnakumarcn picture krishnakumarcn · Oct 11, 2018 · Viewed 35.7k times · Source

While pushing a react native project, I'm getting error due to husky pre-push failed

husky > pre-push hook failed (add --no-verify to bypass)

All these errors shown are lint errors like the below

unused-vars

27:48  error    Trailing spaces not allowed    
                     no-trailing-spaces

75:5   warning  Unexpected console statement   
                     no-console

92:93  error    Unexpected trailing comma   
                        comma-dangle

96:81  error    Unexpected trailing comma

How to turn this off on Sourcetree app on mac?

Answer

krishnakumarcn picture krishnakumarcn · Dec 11, 2018

The issue (even though it's not a real issue! ) is because of the hooks created by React. The solution is to simply delete the hooks folder for git which defines the pre-commit hooks and hence can push after that. (This is just kind of a hack to avoid editing thousands of files at a time for lint errors. Follow the guidelines and resolve all the lint errors for better code quality and maintainability. )

Edit: You can also skip hooks when you provide the git command line argument —no-verify, git push origin master --no-verify, or use Sourcetree‘s Bypass commit hooks setting (in the menu to the top right of the commit message field)