views:

48

answers:

2

Hi

We have a website that has all its PHP/HTML/JS/CSS/etc files stored in a Git repository.

We currently have 3 types of computers (or use cases) for the repository.

  • Local developer: pull latest changes, make changes, commit to local repo, push to master server
  • Master server: central repository, all changes get pushed to the master server
  • Web server: changes are pulled down from the master server when deploying the website

So currently we:

local: git push origin master
local: password: ********
local: ssh [email protected]
webserver: password: ********
webserver: cd ~/domain.com/
webserver: git pull origin master

So my question is: is there a way that from my local computer I can push straight to the web server?

ie.

local: git push origin master
local: password: ********
local: git push webserver master
local: password: ********
A: 

Look at the git urls portion of http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-push.html

so you would try:

git push ssh://[email protected]/~admin/domain.com/ master

ADDED: I think part of what you are asking for is how to have multiple remote repositories.

git remote add webserver ssh://[email protected]/~admin/domain.com/

that allows you to run:

   git push origin master
   git push webserver master
Tim Hoolihan
The problem is that push and pull are not interchangeable. Pushing to a repo will not modify the working branch.
Casey
@Casey, if you read the question, he is just asking how to push, he doesn't mention trying to update the working tree. You're probably right about what he's intending to do, but the down vote seems a bit harsh for taking his question at face value.
Tim Hoolihan
In the question his current workflow is "git pull origin master"
Casey
"So my question is: is there a way that from my local computer I can push straight to the web server?" -and- "local: git push webserver master"
Tim Hoolihan
A: 

I think the feature you are looking for is described here: http://debuggable.com/posts/git-tip-auto-update-working-tree-via-post-receive-hook:49551efe-6414-4e86-aec6-544f4834cda3

From local you can add the webserver as a remote, just like you would do any other:

git remote add webserver admin@webserver:/path/to/repo.git/
# push only master branch by default
git config remote.webserver.push master  

Now when your ready to push you can just do:

git push webserver
Casey