Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:48:56+00:00 2026-06-13T09:48:56+00:00

In a bash script I do a git push and I check its exit

  • 0

In a bash script I do a

git push

and I check its exit status.

On the remote server there’s a post-receive hook which does a few things. If an error occurs the post-receive hook will exit with a non-zero value.

However when the post-receive hook errors out, git push exits normally. Unless I’m specifically checking the output for specific error strings (which I’m not) my script thinks everything went ok.

Is there an easy way for me to determine if the post-receive hook failed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:48:57+00:00Added an answer on June 13, 2026 at 9:48 am

    So the answer is no there is no way to easily check if the post-receive hook failed. The best you can do is have your script check for output from remote and make sure your post-receive hook echos an error message you’re looking for.

    In my case a pre-receive hook won’t work since I’m pushing to another backup repo and the new commit has to be accepted before it can be pushed.

    Basically the post-receive hook should do something like:

     some-command-that-might-fail
    
     RC=$?
    
     if [ $RC -eq 0 ]; then
    echo -e "\nERROR: some-command-that-might-fail FAILED!!!!!!!! PANIC!!!!!!\n"
     fi
    

    Then the script doing the push should grep the output for FAILED or ERROR or PANIC and report the post-receive error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running Gitolite over the Git repository and I have post-receive hook there written
We're using git with a central repo (using Gitosis). I've created a post-receive hook
I'm writing post-receive hook basing on the post-receive-email script from the contrib dir, but
I have written a bash script which installs a number of packages, however for
I'm writing a bash script in which I read single characters from the input.
I have a Bash script on server A that finds the logged in SSH
I'm creating a bash script that will run a process in the background, which
I am using this function in Bash function parse_git_branch { git_status=$(git status 2> /dev/null)
I am writing a bash script where I need to clone a git rep.
Here is the script that I want to run using git filter-branch : #!/bin/bash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.