How to pull changes on remote clone

258 views Asked by At

Good day,

On remote server I have:

  1. repository /git/project.git
  2. clone /individual/user/project/www (remote removed)
  3. clone /alpha/project/www (remote is set)
  4. clone /stable/project/www (remote is set)

On local machine:

  1. clone MAMP/htdocs/project (remote is set)

I use sftp connection to /individual/user/project to see changes in real-time and merging data from /individual/user/project to /alpha/project/ and after testing to /stable/project/

Question is:

  1. how can i by commit+push from local machine auto-update /alpha/project/ and then if everything is fine pull changes on /stable/project/
  2. how can i use special branches to auto-update specific remote folders, e.g.:
    1. by commit+push alpha branch auto-update /alpha/project/
    2. by commit+push stable branch auto-update /stable/project/
  3. how can i pull changes for /stable/project/ from my local machine

P.S. using Terminal, SourceTree, PhpStorm, gitolite
red Pro Git 1st Edition & Pro Git 2nd Edition

1

There are 1 answers

2
Marina Liu On

It’s really possible to pull from local repo/git server to a remote server. The most important thing is you need to create a bare repo on remote server by git init --bare.

More detail steps please refer git clone from local to remote

You can add remote to your local machine as below:

git remote add ind <URL for individual/project>
git remote add alpha <URL for alpha>
git remote add stable <URL for stable>

Then you can commit your local changes by git commit -am 'message'

Push local changes to individual,alpha and stable by git push ind && git push alpha && git push stable

If you want to pull changes to local, you can first check if it’s has remote-tracking branch by git branch -a. Such as if it list stable/master, so you can directly switch to it by git checkout stable/master.

If you want auto pushed to another repo, please refer here.