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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:17:15+00:00 2026-05-26T12:17:15+00:00

I am trying to create a post-receive hook in Nodejs to update my server

  • 0

I am trying to create a post-receive hook in Nodejs to update my server when my Github repo has been updated.

I have done this before in php. I am now using Nodejs and am unsure how it should be acheived.

I have looked at this blog post about setting up nodejs on an ec2 instance. It says:

Create a post-recieve hook that will copy over new code after it’s been pushed to the repository

$ cat > hooks/post-receive

#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/www
export GIT_WORK_TREE
git checkout -f

$ chmod +x hooks/post-receive

I am unsure what exactly the above code is doing and how it should be implemented.

Any ideas on the best way of doing this?

I am running a basic 32-bit Amazon Linux EC2 instance.

  • 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-26T12:17:16+00:00Added an answer on May 26, 2026 at 12:17 pm

    A git bare repository doesn’t include the working tree. So to use the files you have to check them out.

    putting the above script in (pseudo path) ec2:mybaregitrepo/hooks/post-recieve will cause it to run every time you push to ec2.

    Which means:

    #!/bin/sh
    //set git working tree (the files you can use) to the path /home/ubuntu/www
    GIT_WORK_TREE=/home/ubuntu/www
    export GIT_WORK_TREE
    //force git checkout so that your files will be put into the working tree.
    git checkout -f
    

    than:

    //make the post-recieve hook executable so that it can run when you push commits to ec2
    chmod +x hooks/post-receive
    

    here is a decent runthrough of setting up a remote bare git repo
    http://toroid.org/ams/git-website-howto

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

Sidebar

Related Questions

I have gitosis setup on my server and I'm trying to create a post-receive
I'm trying to create a POST request, unfortunately the body of the POST never
I'm trying to create a post button that inserts the latest posts into a
Im trying to create an ajax (post) event that will populate a table in
Help, I'm trying to create a new post in my wordpress blog with custom
I'm trying to create an auto generated post excerpt from the current page's post
I'm trying to create a simple spring based webservice that supports a post with
So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); System.String
I'm trying to create a REST service defined as: @POST @Path(/path) @Consumes(MediaType.APPLICATION_XML) @Produces(multipart/mixed) public
I have been trying to retrieve data via AJAX. I can't seem to be

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.