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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:22:45+00:00 2026-06-18T06:22:45+00:00

Consider the following situation: I have a git repository foo.git that contains code of

  • 0

Consider the following situation:

I have a git repository foo.git that contains code of a javascript project. In this repository there is a branch production that contains the state of the code as served by a web-server which fetches the code from /var/www/foo. This repository is the master repository for the project. Everybody pushes and pulls from/to it.

Is it possible to have /var/www/foo updated to a checkout of production whenever someobody pushes to that particular branch? You may assume that the git daemon (or the user git which is the user all people log in to to connect via SSH) is entitled to write to said directory.

  • 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-18T06:22:47+00:00Added an answer on June 18, 2026 at 6:22 am

    You have to create a bare repository on the server with git init --bare.
    Then use a post-receive hook to trigger your deploy.
    How you deploy is up to you.

    My Deployment Strategy

    I usually place a deploy director, somewhere logical.
    Then each checkout, I unpack the latest branch to deploy/COMMIT_ID where COMMIT_ID is the hash of the latest push. Once the checkout is complete, you can re-point a symlink to the latest deployment directory.

    My usual directory structure:

    deploy.git/
    deploy/
        a7922231/
        b2f0a2af/
        latest -> b2f0a2af 
    

    Unpacking the Update

    Rather than use a git-checkout, I usually use git-archive to unpack a branch into a directory.

    # Assuming current directory is deploy.git
    HEAD=`cat refs/heads/master`
    mkdir -p ../deploy/${HEAD}
    git archive master | tar -x -C ../deploy/${HEAD}
    

    Your web-server can point to deploy/latest, updates will be more-or-less atomic.

    I use this often in production, and has a few benefits over unpacking over the same directory.

    1. rollbacks are easy
    2. you can do post-unpack procedures, like compile or install dependencies without interrupting the current deployment

    Tips

    1. each update, append to a deploy log that says when updates occurred, and what their hash ids are. This makes rollbacks much easier.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following situation: I have an object foo that is used by multiple
Consider the following situation: There is an xml that contains data @XmlData The @XmlData
Consider the following situation. I have 3 tables in a resource planning project(created using
Consider I have the following situation: I have a branch br_foo from revision 4.
Consider the following situation where I have a list of n matrices (this is
Consider the following situation: I have a library that includes a third party library.
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Consider the following situation: I have two android projects named P1 and P2 which
Consider the following situation Code was added to the trunk at revision x A
I have an app that's about presenting fictional simplified cities. Please consider the following

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.