Bypass post-receive hook git












4















Is there a way how to explicitly bypass firing the post-receive hook? Meaning after pushing commit the post-receive hook won't run.










share|improve this question





























    4















    Is there a way how to explicitly bypass firing the post-receive hook? Meaning after pushing commit the post-receive hook won't run.










    share|improve this question



























      4












      4








      4


      1






      Is there a way how to explicitly bypass firing the post-receive hook? Meaning after pushing commit the post-receive hook won't run.










      share|improve this question
















      Is there a way how to explicitly bypass firing the post-receive hook? Meaning after pushing commit the post-receive hook won't run.







      git push githooks






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 2 '14 at 10:01







      user3350906

















      asked Apr 2 '14 at 9:45









      user3350906user3350906

      11519




      11519
























          2 Answers
          2






          active

          oldest

          votes


















          2














          It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to allow that case (skip) to occur.

          This differ from local hooks, that you can skip (for some of them).



          See for example hooks in "Skip processing of Git revisions in post-receive hook that have already been previously processed" (which is about partialy skipping some commits, but the idea is similar)






          share|improve this answer

































            1














            It is quite possible to skip post-receive hook with use of push-options.



            To make is happen you need three ingredients:



            1)



            According to man githooks, post-receive section:




            The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.




            So you can prepare your post-receive hook script like this:



            if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
            exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
            fi


            2)



            According to git-config-receiveadvertisePushOptions:




            When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.




            So you need to add this configuration on your remote like so:



            git config receive.advertisePushOptions true


            Or edit your project.git/config manually.



            3)



            For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:



            git push -o blah


            Using $GIT_PUSH_OPTION_(n) you can make your pushes even more sophisticated.






            share|improve this answer



















            • 1





              Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

              – VonC
              Nov 16 '18 at 5:54














            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22807520%2fbypass-post-receive-hook-git%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to allow that case (skip) to occur.

            This differ from local hooks, that you can skip (for some of them).



            See for example hooks in "Skip processing of Git revisions in post-receive hook that have already been previously processed" (which is about partialy skipping some commits, but the idea is similar)






            share|improve this answer






























              2














              It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to allow that case (skip) to occur.

              This differ from local hooks, that you can skip (for some of them).



              See for example hooks in "Skip processing of Git revisions in post-receive hook that have already been previously processed" (which is about partialy skipping some commits, but the idea is similar)






              share|improve this answer




























                2












                2








                2







                It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to allow that case (skip) to occur.

                This differ from local hooks, that you can skip (for some of them).



                See for example hooks in "Skip processing of Git revisions in post-receive hook that have already been previously processed" (which is about partialy skipping some commits, but the idea is similar)






                share|improve this answer















                It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to allow that case (skip) to occur.

                This differ from local hooks, that you can skip (for some of them).



                See for example hooks in "Skip processing of Git revisions in post-receive hook that have already been previously processed" (which is about partialy skipping some commits, but the idea is similar)







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 23 '17 at 10:31









                Community

                11




                11










                answered Apr 2 '14 at 11:15









                VonCVonC

                851k30127123273




                851k30127123273

























                    1














                    It is quite possible to skip post-receive hook with use of push-options.



                    To make is happen you need three ingredients:



                    1)



                    According to man githooks, post-receive section:




                    The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.




                    So you can prepare your post-receive hook script like this:



                    if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
                    exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
                    fi


                    2)



                    According to git-config-receiveadvertisePushOptions:




                    When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.




                    So you need to add this configuration on your remote like so:



                    git config receive.advertisePushOptions true


                    Or edit your project.git/config manually.



                    3)



                    For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:



                    git push -o blah


                    Using $GIT_PUSH_OPTION_(n) you can make your pushes even more sophisticated.






                    share|improve this answer



















                    • 1





                      Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                      – VonC
                      Nov 16 '18 at 5:54


















                    1














                    It is quite possible to skip post-receive hook with use of push-options.



                    To make is happen you need three ingredients:



                    1)



                    According to man githooks, post-receive section:




                    The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.




                    So you can prepare your post-receive hook script like this:



                    if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
                    exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
                    fi


                    2)



                    According to git-config-receiveadvertisePushOptions:




                    When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.




                    So you need to add this configuration on your remote like so:



                    git config receive.advertisePushOptions true


                    Or edit your project.git/config manually.



                    3)



                    For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:



                    git push -o blah


                    Using $GIT_PUSH_OPTION_(n) you can make your pushes even more sophisticated.






                    share|improve this answer



















                    • 1





                      Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                      – VonC
                      Nov 16 '18 at 5:54
















                    1












                    1








                    1







                    It is quite possible to skip post-receive hook with use of push-options.



                    To make is happen you need three ingredients:



                    1)



                    According to man githooks, post-receive section:




                    The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.




                    So you can prepare your post-receive hook script like this:



                    if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
                    exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
                    fi


                    2)



                    According to git-config-receiveadvertisePushOptions:




                    When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.




                    So you need to add this configuration on your remote like so:



                    git config receive.advertisePushOptions true


                    Or edit your project.git/config manually.



                    3)



                    For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:



                    git push -o blah


                    Using $GIT_PUSH_OPTION_(n) you can make your pushes even more sophisticated.






                    share|improve this answer













                    It is quite possible to skip post-receive hook with use of push-options.



                    To make is happen you need three ingredients:



                    1)



                    According to man githooks, post-receive section:




                    The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,... If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.




                    So you can prepare your post-receive hook script like this:



                    if [ "x${GIT_PUSH_OPTION_COUNT}" = "x0" ] ; then
                    exec /usr/share/buildbot/contrib/git_buildbot.py --master=172.16.1.1:8989 --auth="***" --category=yaal --project=yaal --repository=yaal "${@}"
                    fi


                    2)



                    According to git-config-receiveadvertisePushOptions:




                    When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.




                    So you need to add this configuration on your remote like so:



                    git config receive.advertisePushOptions true


                    Or edit your project.git/config manually.



                    3)



                    For pushes that you do not want for your post-receive hook to fire simply add dummy push option, like so:



                    git push -o blah


                    Using $GIT_PUSH_OPTION_(n) you can make your pushes even more sophisticated.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 16 '18 at 5:49









                    AmokHuginnssonAmokHuginnsson

                    1,01298




                    1,01298








                    • 1





                      Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                      – VonC
                      Nov 16 '18 at 5:54
















                    • 1





                      Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                      – VonC
                      Nov 16 '18 at 5:54










                    1




                    1





                    Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                    – VonC
                    Nov 16 '18 at 5:54







                    Interesting. +1. This comes from github.com/git/git/commit/…, Git v2.10.0-rc0, July 2016, 2 years after my own answer. I mentioned it here: stackoverflow.com/a/38770670/6309

                    – VonC
                    Nov 16 '18 at 5:54




















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22807520%2fbypass-post-receive-hook-git%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Error while running script in elastic search , gateway timeout

                    Adding quotations to stringified JSON object values