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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:36:22+00:00 2026-06-05T08:36:22+00:00

I have the following post-receive hook I wrote on a virtual server such that

  • 0

I have the following post-receive hook I wrote on a virtual server such that it copies the dev and production versions of the repository into dev and production directories where each version of the site is run.

The following is the post-receive hook I wrote. How do I conditionally refresh just one or the other depending on what branch just got pushed?

#!/bin/sh

if [ -n $GIT_DIR ]; then
    unset GIT_DIR
    cd ..
fi

echo "Deploying to dev"
git checkout develop
umask 002 && git reset --hard
cp -r /path/to/git/files/* /path/to/dev/site/

echo "Deploying to prod"
git checkout master
umask 002 && git reset --hard
cp -r /path/to/git/files/* /path/to/prod/site/
  • 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-05T08:36:23+00:00Added an answer on June 5, 2026 at 8:36 am

    Post-receive hooks receives on standard input 3 variables: old revision, new revision and ref name – which is exactly what you need. You can improve your script with:

    read oldrev newrev refname
    

    And do some ifs depending on what refname contains (i.e: refs/heads/master).

    • 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 have the following code: name= a; value=b $.post(ajax.php, {name:value}).... However ajax.php will receive
I have been using post-receive scripts in my git repositories with the following commands
I have been following the following post on using multiple ItemTemplates in a ListView
I have the following POST request: POST http://blah/Request HTTP/1.1 Host: blah Content-Length: 322 Proxy-Connection:
I have the following code: // // POST: /PlayRoundHole/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection)
I have the following models: Post.rb class Post < ActiveRecord::Base belongs_to :category has_many :attachments,
i have the following javascript to post a form through ajax without refreshing the
I have the following data: A post called Hello has categories greet Another post
I have the following javascript: $.post(/Authenticated/DeletePage/ + PageId); showStatus(Page deleted..., 10000); I would like

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.