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 747135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:10:14+00:00 2026-05-14T14:10:14+00:00

I have a post-update hook on my server, such that when I git push

  • 0

I have a post-update hook on my server, such that when I

git push

it does a pull on the live web directory. However, while the push always succeeds, the post-update hook sometimes fails.

The hook is pretty simple:

#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
cd /var/www
env -i git pull

I’m pushing updates from a variety of places, but sometimes I have to login as root on the server and manuall do a

env -i git pull

I only have to do it 20% of the time though. Any ideas why it would fail randomly? Also, how would I get it to log error messages, since it might be running as someone who can’t write to the file system?

  • 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-05-14T14:10:14+00:00Added an answer on May 14, 2026 at 2:10 pm

    The hooks are run as the user doing the push. If you have some kind of pre-made setup, that may be a user like git or gitosis, or it may be you. Just look at how you have the remote configured. (git remote show <remote-name> or just examine .git/config if you don’t know) Presumably you’re pushing via SSH, and there’s a username@hostname in the URL.

    P.S. It’s pretty quick to demonstrate this – just clone a repo locally, throw a post-update hook in with an echo $USER or something similar, and try pushing as yourself or a different user (directly or through ssh).

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

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer <tr> <?php $c = 0; // Our counter $n =… May 16, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer The docs for all fields is e.g. here. 1 is… May 16, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer To get rid of the newline, you can just echo… May 16, 2026 at 5:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to set up a git post-receive hook such that when a commit
Let's say we have a continuous integration server. When I check in, the post-hook
I've got a post-commit hook script that performs a SVN update of a working
I am stuck with that task. I've written svn post-commit hook, that should update
My server has both Subversion and Apache installed, and the Apache web directory is
I have just updated to 1.4.2 and now everything that has worked before does
I am using an SVN repository for my web development work. I have a
I'm using Git to manage my website's source code and deployment, and currently have
I have a project hosted on git.debian.org (alioth) and I'd like to configure a
I have a Model that I can bind correctly for display purposes but I

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.