Git push failed due to husky pre-push on sourcetree
Add --no-verify
flag to the end of your push command.
git push origin master --no-verify
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)
I thought it equally important to help you understand the husky
tool.
And I found this article very helpful in managing this situation, when I struggled too.
Husky is an npm package that lets you define npm scripts that correlate to local Git events such as a commit or push. And this helps in enforcing collaborative standards in a project.
In your project, you mention that all errors are linked to linting.
So in there, husky
scripts were written to create a git hook
, called pre-push
, which enforces code linting before you can git push
successfully.
In my opinion, especially if you are working in a team, DO NOT turn-off/deactivate these checks and DO NOT delete the .git/hooks
folder. Instead go back and run the lint script
(often found in the package.json
), amend the required changes and once you git push
again you'll be successful.