{"id":2571,"date":"2023-03-07T12:28:59","date_gmt":"2023-03-07T11:28:59","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=2571"},"modified":"2023-03-07T12:28:59","modified_gmt":"2023-03-07T11:28:59","slug":"fixes-empyty-git-commit-warning","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2023\/03\/07\/fixes-empyty-git-commit-warning\/","title":{"rendered":"[ FIXES ] empyty git commit warning"},"content":{"rendered":"\n<p>After pushing my code to the remote branch and creating a PR. I made some more changes to my local code and then, when I want to commit the new change and push it to te remote again, I get following &#8220;git warning message&#8221; : <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"663\" height=\"353\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2023\/03\/image.png\" alt=\"\" class=\"wp-image-2572\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2023\/03\/image.png 663w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2023\/03\/image-300x160.png 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/figure>\n\n\n\n<h4>Solution: <\/h4>\n\n\n\n<ul><li>If we Look at the husky line on our screenshot, we have a pre-commit\u00a0<a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Customizing-Git-Git-Hooks\">hook<\/a>\u00a0running here.<\/li><li>The reason it fires would have to be found in the hook itself, but it looks like the linting process deems that we changed only whitespace ( we can check it with\u00a0<code><em><strong>git diff --staged<\/strong><\/em><\/code>\u00a0just before committing).<\/li><\/ul>\n\n\n\n<p>So if we <strong>do<\/strong>\u00a0want to commit only our whitespace changes but the hook prevents it, let us check\u00a0<code><span class=\"has-inline-color has-vivid-cyan-blue-color\">.git\/hooks\/pre-commit<\/span><\/code>\u00a0and consider using\u00a0<em><strong><code>-n<\/code>\u00a0<\/strong><\/em>for our commit command (<a href=\"https:\/\/git-scm.com\/docs\/git-commit#Documentation\/git-commit.txt---no-verify\"><code>--no-verify<\/code><\/a>) to commit without triggering the hook. ( <em><strong>git commit -n<\/strong><\/em> ) <\/p>\n\n\n\n<p>An alternative would be to use<em><strong>\u00a0<code>--allow-empty<\/code><\/strong><\/em>\u00a0as hinted in yellow, but without knowing exactly what&#8217;s in our lint hook, hard to say for sure. Who set up our repo\/workflow? That hook has likely been put here for a reason, so be sure to discuss the matter with them, before doing anything.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After pushing my code to the remote branch and creating a PR. I made some more changes to my local code and then, when I want to commit the new change and push it to te remote again, I get following &#8220;git warning message&#8221; : Solution: If we Look at the husky line on our [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[657,659,655,660,658,656],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2571"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2571"}],"version-history":[{"count":1,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2571\/revisions"}],"predecessor-version":[{"id":2573,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2571\/revisions\/2573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/807"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}