简体   繁体   中英

Git pull from one user account to another

I access a linux server by ssh. I have two user accounts on that server. One user for development and one user for production.

It is about a webapp which runs on public_html folder of each user and I access the application by visiting server_address/~user_account_name

On those accounts using the ssh, I've made some git repositories. In order to make updates to production account, i do a git log --name-status -n3 and copy the files which were modified.

The thing is that I'll like to pull from one account to another but I don't know how to do it.

Can you give me some advices?

Sure, that's easy. First, you have to make sure that the public_html directory within each user account is a git repository. Probably the best way to do this is to

cd /home/production
mv public_html public_html.backup
git clone /home/development/public_html public_html

In order for this to work, you may have to adjust the permissions on the development public_html repository. I'd probably suggest making a group called "website" or something, adding both the production and development users to it, and running

cd /home/development
chgrp --recursive website public_html
chmod --recursive g+wX public_html

Afterwards, whenever you need to copy files from the development site to the production site, you can run

cd /home/production/public_html
git pull origin

You may also be interested in this blog post of mine in which I describe how I manage my website on staging and production servers using git. It's a slightly fancier approach because there are multiple computers involved, but I've found it to work pretty well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM