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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:32:09+00:00 2026-05-20T23:32:09+00:00

How can I set up remote directories in Git where I can locally push

  • 0

How can I set up remote directories in Git where I can locally push a stage branch to the remote and see the live changes on a staging server, like stage.example.com?

The notion I have (part of why I am moving away from SVN) is that I can maintain (locally) 3 different “main” branches as follows:

  • master – used for local development, working dir
  • stage – should be in-sync with staging server directory (remote)
  • live – this should be the publicly accessible website (remote)

The idea I have (and what others claim is possible) is that I can maintain these remote “sites” from my local computer without having to constantly log into my remote server shell and run svn update (in my current svn workflow I need to do this all the time…) or of course in my Git workflow run git pull on the remote.

How can I setup the remote directories so that I can locally push my stage branch to the staging remote server and see the changes on (for example) stage.example.com right away?

Then once the stage is all okay and tested I would just locally be able to push to the live remote to make these changes that I have tested on the stage to the live website.

Can this even be done or am I getting crazy ideas here that are simply not meant to be done with Git?

In case this is of importance here are a few stats about my local and remote servers:

remote server:      Dreamhost (shared account)
remote GIT version: 1.7.1.1
remote GIT client:  shell

local computer:     Mac Pro (Snow Leopard 10.6.6)
local GIT version:  1.7.2.3
local GIT client:   Tower.app // git-tower.com

Also, so far I have unsuccessfully tried the following workflow:

  1. Create a --bare Git repo on the remote (so I can access it from everywhere)
  2. Clone this remote repo to a local directory and the use Git Tower app to manage it
  3. Work locally in master (HEAD)
  4. scp -r copy the --bare git repo from the remote server into my remote live domain stage.example.com
  5. Add remote to local working copy and then try to push to origin/stage

Clearly this doesn’t work but I don’t know why or how to do it any better.

Coming from a SVN background I’m new to Git but have watched plenty of tutorials (Peepcode & ThinkVitamin) but still cannot figure out how to set this up.

  • 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-20T23:32:10+00:00Added an answer on May 20, 2026 at 11:32 pm

    The one notion to realize with a DVCS (“Distributed” VCS, like Git or Mercurial) is that it adds the notion of publication (push/pull) to the notion of branching.
    A CVCS (“Centralized” VCS, like SVN) has only branching (and one central repo to push to on a server).

    In your case, staging or live are publication steps, i.e. different Git repo ready to receive the modifications you want to see in staging or in live environment.

    That would mean:

    • 2 branches to keep track of what belong to staging (“staging” branch) or live (“live” branch)
    • 1 remote bare repo (in order to be able to push to it, pushing either the staging or the live branch
    • 1 post-update hook for the bare repo in order to checkout and update a working tree (representing your actual “staging” or “live” files)
    • 1 local repo where you add the bare repo as remote, and where you can push to staging or to live.
      You can also clone the bare repo to any other local computer you need to work on.

    The difference between a post-receive and a post-update hook is that the post-update one is executed once for every branch modified:
    See the “Git hook to update various web folders based on branch pushed to remote server” SO question.

    On the initial push, do a “git push --all origin” and all branches will be created on the remote bare repo.

    The idea is no pulling should be involved on the server side: Only a git --work-tree=/path/to/your/live/files/ checkout live or git --work-tree=/path/to/your/staging/files/ checkout staging, depending on the parameters of the post-update hook: you only checkout the files of the bare repo into these ‘folders’ on the server.

    If you do a ruby script for your hook, make sure to:

    • use the right shebang: #!/usr/bin/env ruby,
    • surround your git command with backtick should be enough: `git ...`, like in this script,
    • use ENV['HOME'] to specify the homedir of the current user within said script, if you want commands like `cd ~/stagedomain.com` or `--work-tree=~/stagedomain.com` to work (with `~` being set to the right path),
    • if you chose to git pull, unset GIT_DIR on the same line than the other commands like in your other question: `cd ~/stage.mydomain.com && unset GIT_DIR && git pull core stage`.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Eclipse I can set all kinds of preferences for coding style. I'd like
I can set the PHP include path in the php.ini : include_path = /path/to/site/includes/
I can set data in JTable constructor, and then user can change this data
I can set the minimum version required (for example XP SP3) in Inno-Setup by
How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object? You can set
In Vim I can :set wrapscan so that when I do an incremental search,
Is there a way I can set up callbacks on (or automataically log) method
There are environment variables you can set to help debug memory issues on the
Is there a way we can set an Image instead of plain colors as
I have a databound list view and can set all the column widths manually

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.